OFFSET
0,3
LINKS
Rémy Sigrist, Table of n, a(n) for n = 0..8191
Rémy Sigrist, PARI program
EXAMPLE
A368431(42) = 46, so a(46) = 42.
PROG
(PARI) See Links section.
(Python)
from itertools import islice
from functools import reduce
def uniq(r): return reduce(lambda u, e: u if e in u else u+[e], r, [])
def A368431gen(): # generator of A368431
R, aset = [["0", "1"]], set()
while R:
r = R.pop(0)
for b in r:
d = int(b, 2)
if d not in aset: yield d; aset.add(d)
if len(r) > 1: R.append(uniq([r[k]+"0" for k in range(1, len(r))]))
R.append(uniq([r[0]+"0", r[0]+"1"] + [r[k]+"1" for k in range(1, len(r))]))
def agen(): # generator of terms
adict, n = dict(), 0
for i, k in enumerate(A368431gen()):
if k not in adict:
adict[k] = i
while n in adict: yield adict[n]; n += 1
print(list(islice(agen(), 70))) # Michael S. Branicky, Dec 24 2023
CROSSREFS
KEYWORD
AUTHOR
Rémy Sigrist, Dec 24 2023
STATUS
approved