OFFSET
0,10
COMMENTS
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:
0, 0, 0, 0, 0, ... (0, in binary 0, has no runs (by convention), thus at first we have all-0 sequence)
1, 0, 0, 0, 0, ... (1, in binary 1, has one run of length 1)
1, 1, 0, 0, 0, ... (2, in binary 10, has two runs of length 1 both)
2, 0, 0, 0, 0, ... (3, in binary 11, has one run of length 2)
2, 1, 0, 0, 0, ... (4, in binary 100, the rightmost run of length 2 given first, then the second run of length 1)
1, 1, 1, 0, 0, ... (5, in binary 101, has three runs of one bit each)
1, 2, 0, 0, 0, ...
3, 0, 0, 0, 0, ...
3, 1, 0, 0, 0, ...
1, 2, 1, 0, 0, ...
1, 1, 1, 1, 0, ...
2, 1, 1, 0, 0, ...
2, 2, 0, 0, 0, ...
1, 1, 2, 0, 0, ...
1, 3, 0, 0, 0, ...
4, 0, 0, 0, 0, ...
MAPLE
A227186 := 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) ;
a := 1 ;
for i from 2 to nops(bdgs) do
if op(i, bdgs) <> op(i-1, bdgs) then
if ru = k then
return a;
end if;
a := 1 ;
ru := ru+1 ;
else
a := a+1 ;
end if;
end do:
if ru =k then
a ;
else
0 ;
end if;
end proc: # R. J. Mathar, Jul 23 2013
PROG
(Scheme)
(define (A227186bi n k) (cond ((< (A005811 n) (+ 1 k)) 0) ((zero? k) (A136480 n)) (else (A227186bi (A163575 n) (- k 1)))))
(PARI) A227186(n, k)=while(k>=0, for(c=1, n, bittest(n, 0)==bittest(n\=2, 0)&next; k&break; return(c)); n||return; k--) \\ To let A(0, 0)=1 add "!n||!" in front of while(...). TO DO: add default value k=-1 and implement "flattened" sequence, such that A227186(n) yields a(n). _M. Hasler_, Jul 21 2013
CROSSREFS
KEYWORD
AUTHOR
Antti Karttunen, Jul 06 2013
STATUS
approved
