OFFSET
1,2
COMMENTS
Apart from the initial 0, all terms have Hamming weight 2. See De Vlieger et al. (2022). - N. J. A. Sloane, Aug 29 2022
LINKS
Rémy Sigrist, Table of n, a(n) for n = 1..3320
Michael De Vlieger, Thomas Scheuerle, Rémy Sigrist, N. J. A. Sloane, and Walter Trump, The Binary Two-Up Sequence, arXiv:2209.04108 [math.CO], Sep 11 2022.
Rémy Sigrist, PARI program
Rémy Sigrist, PARI program (optimized version)
EXAMPLE
PROG
(PARI) See Links section.
(Python)
from itertools import count, islice
from collections import deque
from functools import reduce
from operator import or_
def A354680_gen(): # generator of terms
aset, aqueue, b, f = {0, 1, 2}, deque([2]), 2, False
yield 0
while True:
for k in count(1):
m, j, j2, r, s = 0, 0, 1, b, k
while r > 0:
r, q = divmod(r, 2)
if not q:
s, y = divmod(s, 2)
m += y*j2
j += 1
j2 *= 2
if s > 0:
m += s*2**b.bit_length()
if m not in aset:
if m.bit_count() > 1:
yield m
aset.add(m)
aqueue.append(m)
if f: aqueue.popleft()
b = reduce(or_, aqueue)
f = not f
break
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist and N. J. A. Sloane, Jun 06 2022
STATUS
approved
