A209281 Start with first run [0,1] then, for n >= 2, the n-th run has length 2^n and is the concatenation of [a(1),a(2),...,a(2^n/2)] and [n-a(1),n-a(2),...,n-a(2^n/2)].
0, 1, 2, 1, 3, 2, 1, 2, 4, 3, 2, 3, 1, 2, 3, 2, 5, 4, 3, 4, 2, 3, 4, 3, 1, 2, 3, 2, 4, 3, 2, 3, 6, 5, 4, 5, 3, 4, 5, 4, 2, 3, 4, 3, 5, 4, 3, 4, 1, 2, 3, 2, 4, 3, 2, 3, 5, 4, 3, 4, 2, 3, 4, 3, 7, 6, 5, 6, 4, 5, 6, 5, 3, 4, 5, 4, 6, 5, 4, 5, 2, 3, 4, 3, 5, 4, 3
Offset: 1
Examples
[0,1] -> [0,1] U [2-0,2-1] = [0,1,2,1] -> [0,1,2,1] U [3-0,3-1,3-2,3-1] = [0,1,2,1,3,2,1,2] etc. From _Gus Wiseman_, Aug 08 2021: (Start) As a triangle without the initial 0, row-lengths A000079: 1 2 1 3 2 1 2 4 3 2 3 1 2 3 2 5 4 3 4 2 3 4 3 1 2 3 2 4 3 2 3 6 5 4 5 3 4 5 4 2 3 4 3 5 4 3 4 1 2 3 2 4 3 2 3 5 4 3 4 2 3 4 3 (End)
Crossrefs
Programs
-
Mathematica
Table[Total[First/@Partition[Append[Differences[Prepend[Join@@Position[Reverse[IntegerDigits[n,2]],1],0]]//Reverse,0],2]],{n,0,100}] (* Gus Wiseman, Aug 08 2021 *)
-
PARI
/* compute 2^15 terms */ v=[0,1];for(n=2,15,v=concat(v,vector(2^n/2,i,n-v[i]));a(n)=v[n];)
-
PARI
a(n) = n--; my(s=1,ns); while((ns=n>>s), n=bitxor(n,ns); s<<=1); hammingweight(n); \\ Kevin Ryde, May 14 2022
Formula
Let T(n)=A010060(n) then for n>=1 a(2n)=a(n)+1-T(n-1) and a(2n+1)=a(n+1)+T(n).
For n>=2 a(n) = a(ceiling(n/2))+T(n-1) hence:
a(n) = Sum_{k=0..ceiling(log(n-1)/log(2))} T(floor((n-1)/2^k)).
For k>=0 a(3*2^k+1)=1 (more precisely a(n)=1 iff n is in A103204), a(2^k+1)=k+1, a(5*2^k+1)=2, a(7*2^k+1)=k+2 etc.
From Gus Wiseman, Aug 18 2021: (Start)
(End)
From Kevin Ryde, May 14 2022: (Start)
a(n) = A089215(n) - 1.
(End)
Comments