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.

A101211 Triangle read by rows: n-th row is length of run of leftmost 1's, followed by length of run of 0's, followed by length of run of 1's, etc., in the binary representation of n.

Original entry on oeis.org

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

Views

Author

Leroy Quet, Dec 13 2004

Keywords

Comments

Row n has A005811(n) elements. In rows 2^(k-1)..2^k-1 we have all the compositions (ordered partitions) of k. Other orderings of compositions: A066099, A108244, and A124734. - Jason Kimberley, Feb 09 2013
A043276(n) = largest term in n-th row. - Reinhard Zumkeller, Dec 16 2013
From the first comment it follows that we have a bijection between the positive integers and the set of all compositions. - Emeric Deutsch, Jul 11 2017
From Robert Israel, Jan 23 2018: (Start)
If n is even, row 2*n is row n with its last element incremented by 1, and row 2*n+1 is row n with 1 appended.
If n is odd, row 2*n+1 is row n with its last element incremented by 1, and row 2*n is row n with 1 appended. (End)

Examples

			Since 9 is 1001 in binary, the 9th row is 1,2,1.
Since 11 is 1011 in binary, the 11th row is 1,1,2.
Triangle begins:
  1;
  1,1;
  2;
  1,2;
  1,1,1;
  2,1;
  3;
  1,3;
		

Crossrefs

A070939(n) gives the sum of terms in row n, while A167489(n) gives the product of its terms. A090996 gives the first column. A227736 lists the terms of each row in reverse order.
Cf. also A227186.
Cf. A318927 (concatenation of each row), A318926 (concatenations of reversed rows).
Cf. A382255 (Heinz numbers of the rows: Product_k prime(T(n,k))).

Programs

  • Haskell
    import Data.List (group)
    a101211 n k = a101211_tabf !! (n-1) !! (k-1)
    a101211_row n = a101211_tabf !! (n-1)
    a101211_tabf = map (reverse . map length . group) $ tail a030308_tabf
    -- Reinhard Zumkeller, Dec 16 2013
    
  • Maple
    # Maple program due to W. Edwin Clark:
    Runs := proc (L) local j, r, i, k; j := 1: r[j] := L[1]: for i from 2 to nops(L) do if L[i] = L[i-1] then r[j] := r[j], L[i] else j := j+1: r[j] := L[i] end if end do: [seq([r[k]], k = 1 .. j)] end proc: RunLengths := proc (L) map(nops, Runs(L)) end proc: c := proc (n) ListTools:-Reverse(convert(n, base, 2)): RunLengths(%) end proc: # Row n is obtained with the command c(n). - Emeric Deutsch, Jul 03 2017
    # Maple program due to W. Edwin Clark, yielding the integer ind corresponding to a given composition (the index of the composition):
    ind := proc (x) local X, j, i: X := NULL: for j to nops(x) do if type(j, odd) then X := X, seq(1, i = 1 .. x[j]) end if: if type(j, even) then X := X, seq(0, i = 1 .. x[j]) end if end do: X := [X]: add(X[i]*2^(nops(X)-i), i = 1 .. nops(X)) end proc; # Clearly, ind(c(n))= n. - Emeric Deutsch, Jan 23 2018
  • Mathematica
    Table[Length /@ Split@ IntegerDigits[n, 2], {n, 38}] // Flatten (* Michael De Vlieger, Jul 11 2017 *)
  • PARI
    apply( {A101211_row(n)=Vecrev((n=vecextract([-1..exponent(n)], bitxor(2*n, bitor(n,1))))[^1]-n[^-1])}, [1..19]) \\ replacing older code by M. F. Hasler, Mar 24 2025
  • Python
    from itertools import groupby
    def arow(n): return [len(list(g)) for k, g in groupby(bin(n)[2:])]
    def auptorow(rows):
        alst = []
        for i in range(1, rows+1): alst.extend(arow(i))
        return alst
    print(auptorow(38)) # Michael S. Branicky, Oct 02 2021
    

Formula

a(n) = A227736(A227741(n)) = A227186(A056539(A227737(n)),A227740(n)) - Antti Karttunen, Jul 27 2013

Extensions

More terms from Emeric Deutsch, Apr 12 2005

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]

A318926 Take the binary expansion of n, starting with the least significant bit, and concatenate the lengths of the runs.

Original entry on oeis.org

1, 11, 2, 21, 111, 12, 3, 31, 121, 1111, 211, 22, 112, 13, 4, 41, 131, 1121, 221, 2111, 11111, 1211, 311, 32, 122, 1112, 212, 23, 113, 14, 5, 51, 141, 1131, 231, 2121, 11121, 1221, 321, 3111, 12111, 111111, 21111, 2211, 11211, 1311, 411, 42, 132, 1122, 222, 2112, 11112, 1212, 312, 33, 123
Offset: 1

Views

Author

N. J. A. Sloane, Sep 09 2018

Keywords

Comments

Obviously this compressed notation is useful only for n < 2047. A227736 is a version which works for all n. [Corrected by M. F. Hasler, Mar 12 2025]

Examples

			n, binary, run lengths, -> a(n)
1, [1], [1] -> 1
2, [0, 1], [1, 1] -> 11
3, [1, 1], [2] ->  2
4, [0, 0, 1], [2, 1] -> 21
5, [1, 0, 1], [1, 1, 1] -> 111
6, [0, 1, 1], [1, 2] -> 12
7, [1, 1, 1], [3] -> 3
8, [0, 0, 0, 1], [3, 1] ->  31,
...
From _M. F. Hasler_, Mar 12 2025: (Start)
For n = 1023 = 2^10-1, n = '1'*10 in binary, so there is only one run of length 10, whence a(n) = 10. This value cannot occur at any other index n.
For n = 1024 = 2^10, n = '1'+'0'*10 in binary, so the run lengths, from right to left, are [10, 1], whence a(n) = 101. The only other index n for which this value occurs is n = 2^101-1.
For n = 1025 = 2^10+1, n = '1'+'0'*9+'1' in binary, so a(n) = 191. This values occurs for the second time as a(n = 2^19), for the third time for a(n = 2^92-2), and for the 4th and last time as a(n = 2^191-1).
Similarly, a(1026) = 1181 appears for the second time at n = 2^19 + 1 = 524289;
  a(1027) = 281 occurs a 2nd, 3rd and 4th time at n = 2^28, (2^81-1)*2 and 2^281-1.
The first duplicate value occurs as a(2047 = 2^11-1) = 11 = a(2). (End)
		

Crossrefs

Cf. A227736 (run lengths in rows instead of concatenation), A101211 (rows in reverse order), A318927 (concatenation in reverse order).

Programs

  • Mathematica
    A318926[n_] := FromDigits[Flatten[IntegerDigits[Map[Length, Split[Reverse[IntegerDigits[n, 2]]]]]]];
    Array[A318926, 100] (* Paolo Xausa, Mar 16 2025 *)
  • PARI
    A318926(n)=eval(strjoin(Vecrev(A101211_row(n)))); \\ M. F. Hasler, Mar 11 2025
  • Python
    from itertools import groupby
    def A318926(n): return int(''.join(str(len(list(g))) for k, g in groupby(bin(n)[:1:-1]))) # Chai Wah Wu, Mar 11 2022
    

Extensions

More terms from M. F. Hasler, Mar 12 2025

A351653 a(n) is the concatenation of the length of each run of digits in the decimal representation of n.

Original entry on oeis.org

1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 11, 2, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 2, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 2, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 2, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 2, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 2, 11, 11
Offset: 0

Views

Author

Eder Vanzei, Feb 16 2022

Keywords

Examples

			a(100) = 12, because the 1st run (1) has length 1 and the 2nd run (00) has length 2.
a(13211) = 1112, because the 1st run (1) has length 1, the 2nd run (3) has length 1, the 3rd run (2) has length 1 and the 4th run (11) has length 2.
		

Crossrefs

Cf. A001462, A318921, A318927 (binary version).

Programs

  • Mathematica
    a[n_] := FromDigits[IntegerDigits[Length /@ Split[IntegerDigits[n]]] // Flatten]; Array[a, 100, 0] (* Amiram Eldar, Feb 16 2022 *)
  • PARI
    a(n) = {my(result = "", count = 0, dig = digits(n), last = dig[1]); for(i = 1, length(dig), current = dig[i]; if (current == last, count++, result = concat(result, Str(count)); count = 1); last = current); result = concat(result, Str(count)); return(eval(result))};
    
  • PARI
    apply( {A351653(n,d=digits(n+!n))=d=concat([0,[k|k<-[1..#n=d[^1]-d[^-1]], n[k]], #d]); fromdigits(d[^1]-d[^-1])}, [0..77]) \\ M. F. Hasler, Aug 21 2025
    
  • Python
    from itertools import groupby
    def A351653(n): return int(''.join(str(len(list(g))) for k, g in groupby(str(n)))) # Chai Wah Wu, Mar 11 2022

A382250 Irregular 3-dimensional table, where layer n is an irregular 2D table with A000041(n) columns, each of which lists the n-bit binary numbers whose run lengths correspond to a given partition.

Original entry on oeis.org

0, 0, 0, 1, 0, 1, 3, 2, 0, 1, 7, 2, 4, 6, 3, 5, 0, 1, 15, 2, 8, 14, 3, 7, 4, 6, 12, 5, 9, 11, 13, 10, 0, 1, 31, 2, 16, 30, 3, 15, 4, 6, 8, 14, 24, 28, 5, 17, 23, 29, 7, 9, 11, 13, 19, 25, 27, 10, 18, 20, 22, 26, 12, 21, 0, 1, 63, 2, 32, 62, 3, 31, 4, 6, 16, 30, 48, 60, 5, 33, 47, 61, 7, 15, 8, 14
Offset: 0

Views

Author

Ali Sada and M. F. Hasler, Mar 24 2025

Keywords

Comments

The n-th layer contains the 2^(n-1) numbers from 0 to 2^(n-1)-1, each of which corresponds, through the run lengths of the digits when written with n bits, uniquely to one of the 2^(n-1) compositions of n. (For example, 000 <=> 3, 001 <=> 2+1; 010 <=> 1+1+1.) The numbers are grouped together in columns which correspond to the distinct partitions of n, so there are A000041(n) of these, where A000041 are the partition numbers.
Numbers that will never be in a top row are listed in A175021 = 6, 11, 13, 14, 20, 22, 23, 25, 26, 27, 28, 29, 30, 38, .... All other numbers will eventually be in a fixed position in the top row of all large enough layers.

Examples

			The table starts as follows:
n = 0: There is A000041(0) = 1 partition of 0, the empty partition, which equals the
       run lengths of the empty sequence of digits of 0 written with 0 binary digits.
       So there is 1 column with just one number, 0:
       0
n = 1: Again there is A000041(1) = 1 partition of 1, so there is 1 column, which
       contains the number 0 written with n = 1 bits, so that run lengths are (1):
       0
n = 2: There are A000041(2) = 2 columns for the two partitions of 2; each column
       contains one number: 0 = 00 <=> partition (2), resp. 1 = 01 <=> (1,1):
       0  1
n = 3: There are A000041(3) = 3 columns for the three partitions of 3,
       corresponding to the 2^2 = 4 compositions which are the run lengths of
       0 = 000 <=> partition (3) in column 1,
       1 = 001 and 3 = 011 (partition 2+1 = 1+2) in column 2,
       and 2 = 010 (partition (1,1,1) or 1+1+1) in column 3:
       0  1  2
          3
n = 4: Here are A000041(4) = 5 columns for the five partitions of 4, corresponding
       to 2^3 = 8 compositions of 4 given as run lengths of the numbers 0, ..., 7
       written with 4 bits: Column 1 holds the number 0 = 0000 <=> partition (4),
       column 2 holds the numbers 1 = 0001 and 7 = 0111 <=> partition 3+1 = 1+3,
       column 3 holds 2 = 0010, 4 = 0100 and 6 = 0110 for 2+1+1 = 1+1+2 = 1+2+1,
       column 4 holds 3 = 0011 for 2+2, and column 5 holds 5 = 0101 for 1+1+1+1:
       0  1  2  3  5
          7  4
             6
n = 5: 0   1   2   3   4   5  10
          15   8   7   6   9
              14      12  11
                          13
n = 6: 0   1   2   3   4   5   7   9  10  12   21
          31  16  15   6  17      11  18
              30       8  23      13  20
                      14  29      19  22
                      24          25  26
                      28          27
		

Crossrefs

Cf. A000041 (partition numbers), A000079 (powers of 2), A007088 (binary numbers), A101211 and A318927 (run lengths of binary numbers).
The number of columns of length 1 in layer n is A000005(n).
Cf. A175021 (numbers never in the first row), A175020 (limit of the first rows without initial 0).

Programs

  • PARI
    {layer(n)=my(M=Map(), C=[], p, i); for(k=1, 2^max(n-1,0), mapisdefined(M, p=vecsort(A101211_row(2^n-k)), &i) || mapput(M, p, i=#C=concat(C,[[]])); C[i]=concat(C[i], k-1)); C}

Formula

If we denote by A(n, c, r) the r-th element of column number c in layer n, then
A(n, c, 1) = c-1 for 1 <= c <= min(n, 6); lim_{n -> oo} A(n, c+1, 1) = A175020(c).
A(n, 2, 2) = 2^(n-1) - 1 is the last element of column 2 for all n > 2.
A(n, 3, 2) = 2^(n-2), and A(n, 3, 3) = 2^(n-1) - 2 is the last element of column 3 for all n > 3.
A(n, 4, 2) = 2^(n-2) - 1 is the last element of column 4 for all n > 4.
Showing 1-5 of 5 results.