cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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.

This page as a plain text file.
%I A227188 #24 Aug 10 2025 19:27:08
%S A227188 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 A227188 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 A227188 0,0,0,0,0,0,0,4,2,2,0,0,0,0,0,0,0,0,0,0,3,3,2
%N 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.
%C A227188 A(n,k) is set to zero if there are fewer runs in n than k+1.
%C A227188 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 A227188 Each row gives the partial sums of the terms on the corresponding row in A227186, up to the first zero.
%H A227188 Antti Karttunen, <a href="/A227188/b227188.txt">The first 141 antidiagonals of the table, flattened</a>
%F A227188 A(n,0) = A136480(n), n>0.
%e A227188 The top-left corner of the array:
%e A227188 row #  row starts as
%e A227188    0    0, 0, 0, 0, 0, ...
%e A227188    1    1, 0, 0, 0, 0, ...
%e A227188    2    1, 2, 0, 0, 0, ...
%e A227188    3    2, 0, 0, 0, 0, ...
%e A227188    4    2, 3, 0, 0, 0, ...
%e A227188    5    1, 2, 3, 0, 0, ...
%e A227188    6    1, 3, 0, 0, 0, ...
%e A227188    7    3, 0, 0, 0, 0, ...
%e A227188    8    3, 4, 0, 0, 0, ...
%e A227188    9    1, 3, 4, 0, 0, ...
%e A227188   10    1, 2, 3, 4, 0, ...
%e A227188   11    2, 3, 4, 0, 0, ...
%e A227188   12    2, 4, 0, 0, 0, ...
%e A227188   13    1, 2, 4, 0, 0, ...
%e A227188   14    1, 4, 0, 0, 0, ...
%e A227188   15    4, 0, 0, 0, 0, ...
%e A227188   16    4, 5, 0, 0, 0, ...
%e A227188 etc.
%e A227188 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 A227188 := proc(n,k)
%p A227188     local bdgs,ru,i,b,a;
%p A227188     bdgs := convert(n,base,2) ;
%p A227188     if nops(bdgs) = 0 then
%p A227188         return 0 ;
%p A227188     end if;
%p A227188     ru := 0 ;
%p A227188     i := 1 ;
%p A227188     b := op(i,bdgs) ;
%p A227188     for i from 2 to nops(bdgs) do
%p A227188         if op(i,bdgs) <> op(i-1,bdgs) then
%p A227188             if ru = k then
%p A227188                 return i-1;
%p A227188             end if;
%p A227188             ru := ru+1 ;
%p A227188         end if;
%p A227188     end do:
%p A227188     if ru =k then
%p A227188         nops(bdgs) ;
%p A227188     else
%p A227188         0 ;
%p A227188     end if;
%p A227188 end proc: # _R. J. Mathar_, Jul 23 2013
%t A227188 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 *)
%o A227188 (Scheme)
%o A227188 (define (A227188 n) (A227188bi (A002262 n) (A025581 n)))
%o A227188 (define (A227188bi n k) (cond ((< (A005811 n) (+ 1 k)) 0) ((zero? k) (A136480 n)) (else (+ (A136480 n) (A227188bi (A163575 n) (- k 1))))))
%Y A227188 Cf. A227192 (row sums). Number of nonzero terms on each row: A005811.
%Y A227188 Cf. also A227186, A227189, A163575.
%K A227188 nonn,tabl,base
%O A227188 0,9
%A A227188 _Antti Karttunen_, Jul 06 2013