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.

Original entry on oeis.org

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

Views

Author

Antti Karttunen, Jul 06 2013

Keywords

Comments

A(n,k) is set to zero if there are fewer runs in n than k+1.
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.
Each row gives the partial sums of the terms on the corresponding row in A227186, up to the first zero.

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

Crossrefs

Cf. A227192 (row sums). Number of nonzero terms on each row: A005811.
Cf. also A227186, A227189, A163575.

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.