OFFSET
0,9
COMMENTS
A(n,k) is set to zero if there are fewer runs in n than k+1.
Equally, when A005811(n) > 1, A(n,k) gives the zero-based bit-index where the (k+2)-th run in the binary expansion of n starts, counted from the least significant end.
Each row gives the partial sums of the terms on the corresponding row in A227186, up to the first zero.
LINKS
Antti Karttunen, The first 141 antidiagonals of the table, flattened
FORMULA
A(n,0) = A136480(n), n>0.
EXAMPLE
The top-left corner of the array:
row # row starts as
0 0, 0, 0, 0, 0, ...
1 1, 0, 0, 0, 0, ...
2 1, 2, 0, 0, 0, ...
3 2, 0, 0, 0, 0, ...
4 2, 3, 0, 0, 0, ...
5 1, 2, 3, 0, 0, ...
6 1, 3, 0, 0, 0, ...
7 3, 0, 0, 0, 0, ...
8 3, 4, 0, 0, 0, ...
9 1, 3, 4, 0, 0, ...
10 1, 2, 3, 4, 0, ...
11 2, 3, 4, 0, 0, ...
12 2, 4, 0, 0, 0, ...
13 1, 2, 4, 0, 0, ...
14 1, 4, 0, 0, 0, ...
15 4, 0, 0, 0, 0, ...
16 4, 5, 0, 0, 0, ...
etc.
For example, for n = 8, whose binary expansion is "1000", we get the run lengths 3 and 1 (scanning from the right), partial sums of which are 3 and 4, thus row 8 begins as A(8,0)=3, A(8,1)=4, A(8,2)=0, ...
MAPLE
A227188 := proc(n, k)
local bdgs, ru, i, b, a;
bdgs := convert(n, base, 2) ;
if nops(bdgs) = 0 then
return 0 ;
end if;
ru := 0 ;
i := 1 ;
b := op(i, bdgs) ;
for i from 2 to nops(bdgs) do
if op(i, bdgs) <> op(i-1, bdgs) then
if ru = k then
return i-1;
end if;
ru := ru+1 ;
end if;
end do:
if ru =k then
nops(bdgs) ;
else
0 ;
end if;
end proc: # R. J. Mathar, Jul 23 2013
MATHEMATICA
Table[PadRight[Rest@FoldList[Plus, 0, Length/@Split[Reverse[IntegerDigits[j, 2]]]], i+1-j][[i+1-j]], {i, 0, 16}, {j, 0, i}]; Wouter Meeussen, Aug 31 2013
PROG
CROSSREFS
KEYWORD
AUTHOR
Antti Karttunen, Jul 06 2013
STATUS
approved