login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

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.
6

%I #21 Apr 02 2017 00:31:18

%S 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,

%T 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,

%U 0,0,0,0,0,0,0,4,2,2,0,0,0,0,0,0,0,0,0,0,3,3,2

%N 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.

%C A(n,k) is set to zero if there are fewer runs in n than k+1.

%C 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.

%C Each row gives the partial sums of the terms on the corresponding row in A227186, up to the first zero.

%H Antti Karttunen, <a href="/A227188/b227188.txt">The first 141 antidiagonals of the table, flattened</a>

%F A(n,0) = A136480(n), n>0.

%e The top-left corner of the array:

%e row # row starts as

%e 0 0, 0, 0, 0, 0, ...

%e 1 1, 0, 0, 0, 0, ...

%e 2 1, 2, 0, 0, 0, ...

%e 3 2, 0, 0, 0, 0, ...

%e 4 2, 3, 0, 0, 0, ...

%e 5 1, 2, 3, 0, 0, ...

%e 6 1, 3, 0, 0, 0, ...

%e 7 3, 0, 0, 0, 0, ...

%e 8 3, 4, 0, 0, 0, ...

%e 9 1, 3, 4, 0, 0, ...

%e 10 1, 2, 3, 4, 0, ...

%e 11 2, 3, 4, 0, 0, ...

%e 12 2, 4, 0, 0, 0, ...

%e 13 1, 2, 4, 0, 0, ...

%e 14 1, 4, 0, 0, 0, ...

%e 15 4, 0, 0, 0, 0, ...

%e 16 4, 5, 0, 0, 0, ...

%e etc.

%e 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, ...

%p A227188 := proc(n,k)

%p local bdgs,ru,i,b,a;

%p bdgs := convert(n,base,2) ;

%p if nops(bdgs) = 0 then

%p return 0 ;

%p end if;

%p ru := 0 ;

%p i := 1 ;

%p b := op(i,bdgs) ;

%p for i from 2 to nops(bdgs) do

%p if op(i,bdgs) <> op(i-1,bdgs) then

%p if ru = k then

%p return i-1;

%p end if;

%p ru := ru+1 ;

%p end if;

%p end do:

%p if ru =k then

%p nops(bdgs) ;

%p else

%p 0 ;

%p end if;

%p end proc: # _R. J. Mathar_, Jul 23 2013

%t 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

%o (Scheme)

%o (define (A227188 n) (A227188bi (A002262 n) (A025581 n)))

%o (define (A227188bi n k) (cond ((< (A005811 n) (+ 1 k)) 0) ((zero? k) (A136480 n)) (else (+ (A136480 n) (A227188bi (A163575 n) (- k 1))))))

%Y Cf. A227192 (row sums). Number of nonzero terms on each row: A005811.

%Y Cf. also A227186, A227189, A163575.

%K nonn,tabl,base

%O 0,9

%A _Antti Karttunen_, Jul 06 2013