OFFSET
0,4
COMMENTS
LINKS
N. J. A. Sloane, Table of n, a(n) for n = 0..4800
Rémy Sigrist, PARI program
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 A354757_gen(): # generator of terms
aset, aqueue, b, f = {0, 1, 2}, deque([2]), 2, False
yield from (0, 0, 1)
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:
yield sum(aqueue)
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, Jun 06 2022
STATUS
approved