OFFSET
0,3
COMMENTS
This sequence is a permutation of the nonnegative integers (with inverse A368432).
LINKS
Rémy Sigrist, Table of n, a(n) for n = 0..8191
Rémy Sigrist, PARI program
EXAMPLE
MATHEMATICA
With[{imax=7}, DeleteDuplicates[Map[FromDigits[#, 2]&, Flatten[NestList[Map[Delete[{If[Length[#]>1, Map[#<>"0"&, Rest[#]], Nothing], Join[{#[[1]]<>"0"}, Map[#<>"1"&, #]]}, 0]&], {{"0", "1"}}, imax-1]]]]] (* Generates terms up to order 7 *) (* Paolo Xausa, Dec 28 2023 *)
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 agen(): # generator of terms
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))]))
print(list(islice(agen(), 70))) # Michael S. Branicky, Dec 24 2023
CROSSREFS
KEYWORD
AUTHOR
Rémy Sigrist, Dec 24 2023
STATUS
approved