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.

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.

This page as a plain text file.
%I A227186 #18 Jul 23 2013 17:56:04
%S A227186 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,
%T A227186 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,
%U A227186 0,0,0,0,0,0,0,1,1,2,0,0,0,0,0,0,0,0,0,0,1,1,2,0
%N 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.
%C A227186 A(n,k) is set to zero if there are less than k+1 runs.
%C A227186 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.
%H A227186 Antti Karttunen, <a href="/A227186/b227186.txt">The first 141 antidiagonals of the table, flattened</a>
%F A227186 A(n,0) = A136480(n), n>0.
%e A227186 The top-left corner of the array:
%e A227186 0, 0, 0, 0, 0, ... (0, in binary 0, has no runs (by convention), thus at first we have all-0 sequence)
%e A227186 1, 0, 0, 0, 0, ... (1, in binary 1, has one run of length 1)
%e A227186 1, 1, 0, 0, 0, ... (2, in binary 10, has two runs of length 1 both)
%e A227186 2, 0, 0, 0, 0, ... (3, in binary 11, has one run of length 2)
%e A227186 2, 1, 0, 0, 0, ... (4, in binary 100, the rightmost run of length 2 given first, then the second run of length 1)
%e A227186 1, 1, 1, 0, 0, ... (5, in binary 101, has three runs of one bit each)
%e A227186 1, 2, 0, 0, 0, ...
%e A227186 3, 0, 0, 0, 0, ...
%e A227186 3, 1, 0, 0, 0, ...
%e A227186 1, 2, 1, 0, 0, ...
%e A227186 1, 1, 1, 1, 0, ...
%e A227186 2, 1, 1, 0, 0, ...
%e A227186 2, 2, 0, 0, 0, ...
%e A227186 1, 1, 2, 0, 0, ...
%e A227186 1, 3, 0, 0, 0, ...
%e A227186 4, 0, 0, 0, 0, ...
%p A227186 A227186 := proc(n,k)
%p A227186     local bdgs,ru,i,b,a;
%p A227186     bdgs := convert(n,base,2) ;
%p A227186     if nops(bdgs) = 0 then
%p A227186         return 0 ;
%p A227186     end if;
%p A227186     ru := 0 ;
%p A227186     i := 1 ;
%p A227186     b := op(i,bdgs) ;
%p A227186     a := 1 ;
%p A227186     for i from 2 to nops(bdgs) do
%p A227186         if op(i,bdgs) <> op(i-1,bdgs) then
%p A227186             if ru = k then
%p A227186                 return a;
%p A227186             end if;
%p A227186             a := 1 ;
%p A227186             ru := ru+1 ;
%p A227186         else
%p A227186             a := a+1 ;
%p A227186         end if;
%p A227186     end do:
%p A227186     if ru =k then
%p A227186         a ;
%p A227186     else
%p A227186         0 ;
%p A227186     end if;
%p A227186 end proc: # _R. J. Mathar_, Jul 23 2013
%o A227186 (Scheme)
%o A227186 (define (A227186 n) (A227186bi (A002262 n) (A025581 n)))
%o A227186 (define (A227186bi n k) (cond ((< (A005811 n) (+ 1 k)) 0) ((zero? k) (A136480 n)) (else (A227186bi (A163575 n) (- k 1)))))
%o A227186 (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
%Y A227186 Used to compute A227183. Cf. also A163575, A227188, A227189.
%K A227186 nonn,tabl,base
%O A227186 0,10
%A A227186 _Antti Karttunen_, Jul 06 2013