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.

Showing 1-5 of 5 results.

A227192 Sum of the partial sums of the run lengths of binary expansion of n, when starting scanning from the least significant end; Row sums of A227188 and A227738.

Original entry on oeis.org

1, 3, 2, 5, 6, 4, 3, 7, 8, 10, 9, 6, 7, 5, 4, 9, 10, 12, 11, 14, 15, 13, 12, 8, 9, 11, 10, 7, 8, 6, 5, 11, 12, 14, 13, 16, 17, 15, 14, 18, 19, 21, 20, 17, 18, 16, 15, 10, 11, 13, 12, 15, 16, 14, 13, 9, 10, 12, 11, 8, 9, 7, 6, 13, 14, 16, 15, 18, 19, 17, 16
Offset: 1

Views

Author

Antti Karttunen, Jul 06 2013

Keywords

Comments

Equivalently, sum of bit-indices in binary expansion of n (counted from the right hand end, with the least significant bit having bit-index 0) of the positions where a bit differs from its immediate right-hand neighbor, counted up to the first leading zero.
a(0) could be 0 or 1, depending on how the binary expansion of zero is conceived, thus its value is left unspecified here.
From Jason Kimberley, Feb 22 2022: (Start)
Also, the total length of string movement required to display the binary expansion of n by the positions of the vanes of vertical blinds (starting with all 0).
The transitions from 0000 to 1011 are:
0001, 0011, 0111, 1111;
1110, 1100, 1000;
The transitions from 0000 to 1101 are:
0001, 0011, 0111, 1111;
1110, 1100;
1101. (End)

Examples

			For 11, whose binary expansion is "1011", the run lengths, when starting scanning from the right, are: [2,1,1]. Their partial sums are [2,2+1,2+1+1] = [2,3,4] which sum to total 9, thus a(11)=9. Equivalently, the zero-based positions (counted from the right) where bits change from one to zero or vice versa in "...01011" are 2, 3, 4 and 2+3+4 = 9.
For 13, whose binary expansion is "1101", the run lengths similarly scanned are [1,1,2]. Their partial sums are [1,1+1,1+1+2] = [1,2,4] which sum to total 7, thus a(13)=7. Equivalently, the positions where bits change in "...01101" are 1, 2, 4 and 1+2+4 = 7.
		

Crossrefs

Cf. A005811, A227183. Row sums of A227188 and A227738.

Programs

  • Mathematica
    Table[Tr[FoldList[Plus,0,Length /@ Split[Reverse[IntegerDigits[n,2]]]] ],{n,71}] (* Wouter Meeussen, Aug 22 2013 *)
  • PARI
    a(n)=local(b,s,t);b=binary(n);s=#b;t=b[#b];forstep(i=#b-1,1,-1,if(b[i]!=t,s=s+#b-i;t=!t));s /* Ralf Stephan, Sep 04 2013 */
    
  • Python
    def A227192(n):
      '''Sum of the partial sums of the run lengths of binary expansion of n, starting from the least significant end.'''
      s = 0
      b = n%2
      i = 0
      while (n != 0):
        n >>= 1
        i += 1
        if((n%2) != b):
          b = n%2
          s += i
      return(s)
    
  • Ruby
    def a(n)
      k = n.to_s(2).scan(/((\d)\2*)/)
      k.each_index.map { |i| (i + 1) * k[i][0].size }.reduce(:+)
    end # Peter Kagey, Aug 06 2015
  • Scheme
    (define (A227192 n) (let loop ((i (- (A005811 n) 1)) (s 0)) (cond ((< i 0) s) (else (loop (- i 1) (+ s (A227188bi n i))))))) ;; This version sums the nonzero terms of the n-th row of table A227188.
    (define (A227192v2 n) (+ (A227183 n) (A000217 (- (A005811 n) 1)))) ;; Another variant.
    (define (A227192v3 n) (add A227738 (+ 1 (A173318 (- n 1))) (A173318 n))) ;; This sums terms of table A227738.
    ;; With the help of this function that implements Sum_{i=lowlim..uplim} intfun(i)
    (define (add intfun lowlim uplim) (let sumloop ((i lowlim) (res 0)) (cond ((> i uplim) res) (else (sumloop (1+ i) (+ res (intfun i)))))))
    

Formula

a(n) = Sum_{i=0..A005811(n)-1} A227188(n,i). [Row sums of A227188]
Equivalently, for n>=1, a(n) = Sum_{i=(A173318(n-1)+1)..A173318(n)} A227738(i). [Row sums of A227738]
a(n) = A227183(n) + A000217(A005811(n)-1). [Alternative definition]
a(n) = A029931(A003188(n)).
Recurrence: a(2n) = a(n) + 2*A069010(n), a(2n+1) = a(2n) +1 or -1, according to if n is even or odd. - Ralf Stephan, Sep 04 2013

A227189 Square array A(n>=0,k>=0) where A(n,k) gives the (k+1)-th part of the unordered partition which has been encoded in the binary expansion of n, as explained in A227183. The array is scanned antidiagonally as A(0,0), A(0,1), A(1,0), A(0,2), A(1,1), etc.

Original entry on oeis.org

0, 0, 1, 0, 0, 1, 0, 0, 1, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2
Offset: 0

Views

Author

Antti Karttunen, Jul 06 2013

Keywords

Comments

Discarding the trailing zero terms, on each row n there is a unique partition of integer A227183(n). All possible partitions of finite natural numbers eventually occur. The first partition that sums to n occurs at row A227368(n).
Irregular table A227739 lists only the nonzero terms.

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, 1, 0, 0, 0, ...
    3  2, 0, 0, 0, 0, ...
    4  2, 2, 0, 0, 0, ...
    5  1, 1, 1, 0, 0, ...
    6  1, 2, 0, 0, 0, ...
    7  3, 0, 0, 0, 0, ...
    8  3, 3, 0, 0, 0, ...
    9  1, 2, 2, 0, 0, ...
   10  1, 1, 1, 1, 0, ...
   11  2, 2, 2, 0, 0, ...
   12  2, 3, 0, 0, 0, ...
   13  1, 1, 2, 0, 0, ...
   14  1, 3, 0, 0, 0, ...
   15  4, 0, 0, 0, 0, ...
   16  4, 4, 0, 0, 0, ...
   17  1, 3, 3, 0, 0, ...
etc.
8 has binary expansion "1000", whose runlengths are [3,1] (the length of the run in the least significant end comes first) which maps to nonordered partition {3+3} as explained in A227183, thus row 8 begins as 3, 3, 0, 0, ...
17 has binary expansion "10001", whose runlengths are [1,3,1] which maps to nonordered partition {1,3,3}, thus row 17 begins as 1, 3, 3, ...
		

Crossrefs

Only nonzero terms: A227739. Row sums: A227183. The product of nonzero terms on row n>0 is A227184(n). Number of nonzero terms on each row: A005811. The leftmost column, after n>0: A136480. The rightmost nonzero term: A227185.
Cf. A227368 and also arrays A227186 and A227188.

Programs

A227738 Irregular table read by rows: each row n (n>=1) lists the positions where the runs of bits change between 0's and 1's in the binary expansion of n, when scanning it from the least significant to the most significant end.

Original entry on oeis.org

1, 1, 2, 2, 2, 3, 1, 2, 3, 1, 3, 3, 3, 4, 1, 3, 4, 1, 2, 3, 4, 2, 3, 4, 2, 4, 1, 2, 4, 1, 4, 4, 4, 5, 1, 4, 5, 1, 2, 4, 5, 2, 4, 5, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 3, 4, 5, 3, 4, 5, 3, 5, 1, 3, 5, 1, 2, 3, 5, 2, 3, 5, 2, 5, 1, 2, 5, 1, 5, 5, 5, 6, 1, 5, 6, 1, 2, 5, 6
Offset: 1

Views

Author

Antti Karttunen, Jul 25 2013

Keywords

Comments

Row n has A005811(n) terms.
As a sequence, seems to have a particular fractal structure, probably allowing additional formulas.
Row n lists the positions of 1-bits in the binary expansion of the Gray code for n, A003188(n), when 1 is the rightmost position. A003188(17) = 25 = 11001_2 gives row 17: 1,4,5. - Alois P. Heinz, Feb 01 2023

Examples

			Table begins as:
  Row  n in    Terms on
   n   binary  that row
   1      1    1;
   2     10    1,2;
   3     11    2;
   4    100    2,3;
   5    101    1,2,3;
   6    110    1,3;
   7    111    3;
   8   1000    3,4;
   9   1001    1,3,4;
  10   1010    1,2,3,4;
  11   1011    2,3,4;
  12   1100    2,4;
  13   1101    1,2,4;
  14   1110    1,4;
  15   1111    4;
  16  10000    4,5;
etc.
The terms also give the partial sums of runlengths, when the binary expansion of n is scanned from the least significant to the most significant end.
		

Crossrefs

Each row n (n>=1) contains the initial A005811(n) nonzero terms from the beginning of row n of A227188. A227192(n) gives the sum of terms on row n. A136480 gives the first column.
Cf. also A227188, A227736, A227739.
A318926 is a compressed version. If the order is reversed we get A101211 and A318927.

Programs

  • Maple
    T:= n-> (l-> seq(`if`(l[i]=1, i, [][]), i=1..nops(l)))(
                     Bits[Split](Bits[Xor](n, iquo(n, 2)))):
    seq(T(n), n=1..50);  # Alois P. Heinz, Feb 01 2023
  • Mathematica
    Table[Rest@FoldList[Plus,0,Length/@Split[Reverse[IntegerDigits[n,2]]]],{n,34}]//Flatten (* Wouter Meeussen, Aug 31 2013 *)

Formula

a(n) = A227188(A227737(n),A227740(n)).
Alternatively, if A227740(n) is 0, then a(n) = A227736(n), otherwise a(n) = a(n-1) + A227736(n). [Each row gives cumulative sums of the runlengths of binary representation of 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.

Original entry on oeis.org

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, 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, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 0
Offset: 0

Views

Author

Antti Karttunen, Jul 06 2013

Keywords

Comments

A(n,k) is set to zero if there are less than k+1 runs.
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.

Examples

			The top-left corner of the array:
0, 0, 0, 0, 0, ... (0, in binary 0, has no runs (by convention), thus at first we have all-0 sequence)
1, 0, 0, 0, 0, ... (1, in binary 1, has one run of length 1)
1, 1, 0, 0, 0, ... (2, in binary 10, has two runs of length 1 both)
2, 0, 0, 0, 0, ... (3, in binary 11, has one run of length 2)
2, 1, 0, 0, 0, ... (4, in binary 100, the rightmost run of length 2 given first, then the second run of length 1)
1, 1, 1, 0, 0, ... (5, in binary 101, has three runs of one bit each)
1, 2, 0, 0, 0, ...
3, 0, 0, 0, 0, ...
3, 1, 0, 0, 0, ...
1, 2, 1, 0, 0, ...
1, 1, 1, 1, 0, ...
2, 1, 1, 0, 0, ...
2, 2, 0, 0, 0, ...
1, 1, 2, 0, 0, ...
1, 3, 0, 0, 0, ...
4, 0, 0, 0, 0, ...
		

Crossrefs

Used to compute A227183. Cf. also A163575, A227188, A227189.

Programs

  • Maple
    A227186 := 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) ;
        a := 1 ;
        for i from 2 to nops(bdgs) do
            if op(i,bdgs) <> op(i-1,bdgs) then
                if ru = k then
                    return a;
                end if;
                a := 1 ;
                ru := ru+1 ;
            else
                a := a+1 ;
            end if;
        end do:
        if ru =k then
            a ;
        else
            0 ;
        end if;
    end proc: # R. J. Mathar, Jul 23 2013
  • 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
  • Scheme
    (define (A227186 n) (A227186bi (A002262 n) (A025581 n)))
    (define (A227186bi n k) (cond ((< (A005811 n) (+ 1 k)) 0) ((zero? k) (A136480 n)) (else (A227186bi (A163575 n) (- k 1)))))
    

Formula

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

A043284 Maximal run length in base-10 representation of n.

Original entry on oeis.org

1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2
Offset: 1

Views

Author

Keywords

Comments

The first term larger than 2 is a(111) = 3. - M. F. Hasler, Jul 21 2013

Crossrefs

Cf. A043276-A043290 for base-2 to base-16 analogs.
Cf. A030556-A030561, A030575-A030580 (related to base-6 run lengths).
Cf. A227186, A227188, A101211, A005811 (related to base-2 run lengths).

Programs

  • Mathematica
    A043284[n_]:=Max[Map[Length,Split[IntegerDigits[n]]]];Array[A043284,100] (* Paolo Xausa, Sep 27 2023 *)
  • PARI
    A043284(n)={my(m,c=1);while(n>0,n%10==(n\=10)%10 && c++ && next;m=max(m,c);c=1);m} \\ M. F. Hasler, Jul 23 2013

Formula

For n < 111, a(n) = 1 except for a(n) = 2 when n==0 (mod 11) or n = 100. - M. F. Hasler, Jul 21 2013

Extensions

Data completed up to a(100), first difference with A083230, by M. F. Hasler, Oct 18 2019
Showing 1-5 of 5 results.