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-3 of 3 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

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

Original entry on oeis.org

1, 11, 2, 12, 111, 21, 3, 13, 121, 1111, 112, 22, 211, 31, 4, 14, 131, 1211, 122, 1112, 11111, 1121, 113, 23, 221, 2111, 212, 32, 311, 41, 5, 15, 141, 1311, 132, 1212, 12111, 1221, 123, 1113
Offset: 1

Views

Author

N. J. A. Sloane, Sep 09 2018

Keywords

Comments

Obviously this compressed notation is useful only for n < 1023. A101211 is a version which works for all n.

Examples

			n, binary, run lengths, -> a(n)
1, [1], [1] -> 1
2, [1, 0], [1, 1] -> 11
3, [1, 1], [2] -> 2
4, [1, 0, 0], [1, 2] -> 12
5, [1, 0, 1], [1, 1, 1] -> 111
6, [1, 1, 0], [2, 1] -> 21
7, [1, 1, 1], [3] -> 3
...
		

Crossrefs

Cf. A101211 (without concatenation, as rows), A227736 (rows reversed), A318926 (reverse concatenation).
Cf. A382255 (Heinz numbers instead of concatenation of the run lengths).

Programs

  • Mathematica
    Array[FromDigits@ Flatten[IntegerDigits@ Length[#] & /@ Split@ IntegerDigits[#, 2]] &, 40] (* Michael De Vlieger, Feb 17 2022 *)
  • PARI
    a(n) = { my(d=[], r); while(n, n>>=r=valuation(n+n%2, 2); d=concat(digits(r), d)); fromdigits(d) } \\ Rémy Sigrist, Feb 17 2022, edited by M. F. Hasler, Mar 11 2025
    
  • Python
    from itertools import groupby
    def A318927(n): return int(''.join(str(len(list(g))) for k, g in groupby(bin(n)[2:]))) # Chai Wah Wu, Mar 11 2022

A382256 Smallest binary number whose run lengths of bits correspond to a partition with Heinz number n.

Original entry on oeis.org

0, 1, 3, 2, 7, 4, 15, 5, 12, 8, 31, 11, 63, 16, 24, 10, 127, 19, 255, 23, 48, 32, 511, 22, 56, 64, 51, 47, 1023, 39, 2047, 21, 96, 128, 112, 44, 4095, 256, 192, 46, 8191, 79, 16383, 95, 103, 512, 32767, 45, 240, 71, 384, 191, 65535, 76, 224, 94, 768, 1024, 131071, 92, 262143, 2048, 207, 42, 448, 159
Offset: 1

Views

Author

M. F. Hasler, Mar 19 2025

Keywords

Comments

This is another way of assigning a canonical representative (natural number and composition) to any partition, and therefore to define an order on the set of all partitions.
Since the binary number corresponding to a partition of n is in the interval [2^(n-1), 2^n-1], it does respect the primary order criterion of all classical partition orderings (Abramowitz and Stegun or Hindenburg order: A036036, "Maple order": A080576, "Mathematica order": A080577, ...) which is the sum of the partitions. This is not the case for the Heinz number, cf. Examples.

Examples

			Heinz number 1 corresponds to the empty product, empty sum and partition which is that of a(1) = 0.
Heinz number 2 = prime(1) corresponds to the partition (1), and run lengths of the binary number a(2) = 1 which has just one bit 1.
Heinz number 3 = prime(2) corresponds to the partition (2), which equals the run lengths of the binary number 11[2] = 3 = a(3) which has two consecutive bits 1.
Heinz number 4 = prime(1)^2 corresponds to the partition (1,1), which equals the run lengths of the binary number 10[2] = 2 = a(4) which has one bit 1, then one bit 0.
Heinz number 5 = prime(3) corresponds to the partition (3), which equals the run lengths of the binary number 111[2] = 7 = a(5) which has three consecutive bits 1.
Heinz number 6 = prime(1)*prime(2) corresponds to the partition (1,2), which equals the run lengths of the binary number 100[2] = 4 = a(6).
Heinz number 7 = prime(4) corresponds to the partition (4), which equals the run lengths of the binary number 1111[2] = 15 = a(7).
Heinz number 8 = prime(1)^3 corresponds to the partition (1,1,1), which equals the run lengths of the binary number 101[2] = 5 = a(8). Here, we have a partition with smaller sum than the previous one, but with a larger Heinz number. This shows that ordering the partitions by their Heinz number puts partitions with smaller sums behind partitions with larger sums. The binary numbers, however, do increase with increasing sum of the partition.
Similarly, Heinz number 14 = 2*7 = prime(1)*prime(4) corresponds to the partition (1,4) of 5, which equals the run lengths of the binary number 10000[2] = 16 = a(14), while the larger Heinz number 16 = 2^4 = prime(1)^4 corresponds to the partition (1,1,1,1) with smaller sum 4, and run lengths of the smaller binary number 1010[2] = 10 = a(16).
		

Crossrefs

Cf. A382255, A036036, A080576, A080577 (partitions in Abramowitz-Stegun, Maple and Mathematica order).

Programs

  • PARI
    apply( {A382256(n)=if(n=factor(n)~, n[1,]=apply(primepi, n[1,]); my(i=1, b, L, R=2^n[1,1]-1); n=Vec(n); while(n[i][2]-- || n=n[^i], R<<=L=n[i=b*#n+!b][1]; b && R+=2^L-1; b=1-b); R)}, [1..66])
Showing 1-3 of 3 results.