OFFSET
1,4
COMMENTS
The n-th row lists the numbers from 0 to 2^n-2 in such a way that the binary expansions of adjacent terms are disjoint.
Inspired by A109812.
LINKS
N. J. A. Sloane, Table of n, a(n) for n = 1..16369
N. J. A. Sloane, Row 14 in full: 16383 terms. The numbers from 0 to 2^14-2 arranged so that adjacent terms have disjoint binary expansions. [Note this is not a b-file]
EXAMPLE
The initial rows are:
[0]
[0, 1, 2]
[0, 3, 4, 1, 2, 5, 6]
[0, 7, 8, 3, 4, 11, 12, 1, 6, 9, 2, 5, 10, 13, 14]
[0, 15, 16, 7, 8, 23, 24, 3, 12, 19, 4, 11, 20, 27, 28, 1, 14, 17, 6, 9, 22, 25, 2, 13, 18, 5, 10, 21, 26, 29, 30]
...
MAPLE
T:=proc(n) option remember; local t1, t2, k;
if n=1 then [0];
else
t1:=[seq(2*T(n-1)[k+1] + (k mod 2), k=0..2^(n-1)-2 )];
t2:=[seq(2*T(n-1)[k+1] + (k+1 mod 2), k=0..2^(n-1)-2 )];
[op(t1), op(t2), 2^n-2];
fi;
end;
[seq(T(n), n=1..8)];
MATHEMATICA
T[n_] := T[n] = Module[{t1, t2, k},
If[n == 1, {0},
t1 = Table[2*T[n-1][[k+1]] + Mod[k, 2], {k, 0, 2^(n-1)-2}];
t2 = Table[2*T[n-1][[k+1]] + Mod[k+1, 2], {k, 0, 2^(n-1)-2}];
{t1, t2, 2^n-2} // Flatten]];
Table[T[n], {n, 1, 8}] // Flatten (* Jean-François Alcover, Jul 07 2022, after Maple code *)
CROSSREFS
KEYWORD
nonn,tabf
AUTHOR
N. J. A. Sloane, Apr 08 2022
STATUS
approved