A227188 Square array A(n,k) read by antidiagonals: the one-based bit-index where the (k+1)-st run in the binary expansion of n ends, as read from the least significant end.
0, 0, 1, 0, 0, 1, 0, 0, 2, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 2
Offset: 0
Examples
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, ...
Links
- Antti Karttunen, The first 141 antidiagonals of the table, flattened
Crossrefs
Programs
-
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,12},{j,0,i}] (* Wouter Meeussen, Aug 31 2013 *)
-
Scheme
(define (A227188 n) (A227188bi (A002262 n) (A025581 n))) (define (A227188bi n k) (cond ((< (A005811 n) (+ 1 k)) 0) ((zero? k) (A136480 n)) (else (+ (A136480 n) (A227188bi (A163575 n) (- k 1))))))
Formula
A(n,0) = A136480(n), n>0.
Comments