|
|
A227186
|
|
Array A(n,k) read by antidiagonals: the length of the (k+1)-th run (k>=0) of binary digits of n, first run starting from the least significant bit of n.
|
|
7
|
|
|
0, 0, 1, 0, 0, 1, 0, 0, 1, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 0
(list;
table;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
0,10
|
|
COMMENTS
|
A(n,k) is set to zero if there are less than k+1 runs.
The irregular table A101211 gives the nonzero terms of each row in reverse order. The terms on row n sum to A029837(n+1). The product of nonzero terms on row n>0 is A167489(n). Number of nonzero terms on each row: A005811.
|
|
LINKS
|
|
|
FORMULA
|
|
|
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
|
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;
|
|
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
|
|
|
STATUS
|
approved
|
|
|
|