login
Irregular triangle B(n,i) = i-th significant bit of Gray code of n.
0

%I #29 Sep 08 2022 08:45:47

%S 0,1,1,1,0,1,0,1,1,1,1,1,1,0,1,0,0,1,0,0,1,1,1,0,1,1,1,1,1,1,0,1,1,1,

%T 0,1,0,1,1,1,0,1,1,0,0,1,0,0,0,1,0,0,0,1,1,1,0,0,1,1,1,1,0,1,1,0,1,0,

%U 1,1,0,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0,0,1,1,1,0,0,1,0,1,1,0,1,0,1,1,1,1,0,1

%N Irregular triangle B(n,i) = i-th significant bit of Gray code of n.

%C The n-th row has length A070939(n); a nondecreasing sequence.

%C Each row, when interpreted as a finite sequence can be mapped via Euler's Transform to familiar integer sequences.

%C Note that adjacent rows differ by only one "bit" which simplifies the transition from one row to the next. (cf. A003188, A055975 and A119972).

%F The n-th row is the reversed bit string of A003188(n). Namely, A003188(n) = Sum_{0<=i<A070939(n)} B(n,i) 2^i.

%e The triangle begins: 0 1 11 01 011 111 101 001 0011 1011 1111 0111 0101 1101 1001 0001 00011 10011 11011 11111 ...

%p B:= proc(n) option remember; local b; b:= ilog2(n);

%p `if`(n<=1, n, zip((x, y)->x+y, [B(2^(b+1)-1-n)], [0$b, 1], 0)[])

%p end:

%p seq(B(n), n=0..30); # _Alois P. Heinz_, May 21 2012

%t zip = With[{m = Max[Length[#1], Length[#2]]}, PadRight[#1, m] + PadRight[#2, m]]&; B[n_] := B[n] = With[{b = Floor[Log[2, n]]}, If[n <= 1, {n}, zip[B[2^(b+1)-1-n], Append[Array[0&, b], 1]]]]; Table[B[n], {n, 0, 30}] // Flatten (* _Jean-François Alcover_, Feb 13 2017, after _Alois P. Heinz_ *)

%o (Magma) // Recursive

%o N := 5; s := [[]];

%o for n in [1..N] do

%o for j in [#s..1 by -1] do

%o Append(~s,Append(s[j],1));

%o Append(~s[j],0);

%o end for;

%o end for;

%o &cat[IntegerToSequence(SequenceToInteger(b,2),2):b in s];

%o (Magma) // Direct

%o B:=func<n|[(s[i]+s[i+1])mod 2:i in[1..#s-1]]cat[s[#s]]where s is IntegerToSequence(n,2)>;

%Y Euler transforms of the rows begin: A000007, A000012, A008619, A059841, A103221, A001399, A008620, A022003, A008679, A025767, A001400.

%K nonn,easy,tabf

%O 0

%A _Alford Arnold_, Sep 29 2009

%E Edited by _Jason Kimberley_, Mar 31 2012