A368431 Distinct values of A367562, in order of appearance and with offset 0.
0, 1, 2, 3, 4, 5, 6, 7, 10, 8, 9, 11, 12, 13, 14, 15, 20, 21, 18, 22, 16, 17, 19, 23, 24, 25, 26, 27, 28, 29, 30, 31, 42, 40, 41, 43, 44, 36, 37, 45, 34, 38, 46, 32, 33, 35, 39, 47, 50, 48, 49, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 84, 85, 82, 86
Offset: 0
Examples
The first terms of A367562 and of the present sequence are: k A367562(k) n a(n) -- ---------- -- ---- 1 0 0 0 2 1 1 1 3 2 2 2 4 0 5 1 6 3 3 3 7 4 4 4 8 5 5 5 9 2 10 6 6 6 11 0 12 1 13 3 14 7 7 7 15 10 8 10
Links
- Rémy Sigrist, Table of n, a(n) for n = 0..8191
- Rémy Sigrist, PARI program
- Index entries for sequences that are permutations of the natural numbers
Programs
-
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 *)
-
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
Comments