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-10 of 35 results. Next

A066099 Triangle read by rows, in which row n lists the compositions of n in reverse lexicographic order.

Original entry on oeis.org

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

Views

Author

Alford Arnold, Dec 30 2001

Keywords

Comments

The representation of the compositions (for fixed n) is as lists of parts, the order between individual compositions (for the same n) is (list-)reversed lexicographic; see the example by Omar E. Pol. - Joerg Arndt, Sep 03 2013
This is the standard ordering for compositions in this database; it is similar to the Mathematica ordering for partitions (A080577). Other composition orderings include A124734 (similar to the Abramowitz & Stegun ordering for partitions, A036036), A108244 (similar to the Maple partition ordering, A080576), etc (see crossrefs).
Factorize each term in A057335; sequence records the values of the resulting exponents. It also runs through all possible permutations of multiset digits.
This can be regarded as a table in two ways: with each composition as a row, or with the compositions of each integer as a row. The first way has A000120 as row lengths and A070939 as row sums; the second has A001792 as row lengths and A001788 as row sums. - Franklin T. Adams-Watters, Nov 06 2006
This sequence includes every finite sequence of positive integers. - Franklin T. Adams-Watters, Nov 06 2006
Compositions (or ordered partitions) are also generated in sequence A101211. - Alford Arnold, Dec 12 2006
The equivalent sequence for partitions is A228531. - Omar E. Pol, Sep 03 2013
The sole partition of zero has no components, not a single component of length one. Hence the first nonempty row is row 1. - Franklin T. Adams-Watters, Apr 02 2014 [Edited by Andrey Zabolotskiy, May 19 2018]
See sequence A261300 for another version where the terms of each composition are concatenated to form one single integer: (0, 1, 2, 11, 3, 21, 12, 111,...). This also shows how the terms can be obtained from the binary numbers A007088, cf. Arnold's first Example. - M. F. Hasler, Aug 29 2015
The k-th composition in the list is obtained by taking the set of positions of 1's in the reversed binary expansion of k, prepending 0, taking first differences, and reversing again. This is described as the standard ordering used in the OEIS, although the sister sequence A228351 is also sometimes considered to be canonical. Both sequences define a bijective correspondence between nonnegative integers and integer compositions. - Gus Wiseman, May 19 2020
First differences of A030303 = positions of bits 1 in the concatenation A030190 (= A030302) of numbers written in binary (A007088). - Indices of record values (= first occurrence of n) are given by A005183: a(A005183(n)) = n, cf. FORMULA for more. - M. F. Hasler, Oct 12 2020
The geometric mean approaches the Somos constant (A112302). - Jwalin Bhatt, Feb 10 2025

Examples

			A057335 begins 1 2 4 6 8 12 18 30 16 24 36 ... so we can write
  1 2 1 3 2 1 1 4 3 2 2 1 1 1 1 ...
  . . 1 . 1 2 1 . 1 2 1 3 2 1 1 ...
  . . . . . . 1 . . . 1 . 1 2 1 ...
  . . . . . . . . . . . . . . 1 ...
and the columns here gives the rows of the triangle, which begins
  1
  2; 1 1
  3; 2 1; 1 2; 1 1 1
  4; 3 1; 2 2; 2 1 1; 1 3; 1 2 1; 1 1 2; 1 1 1 1
  ...
From _Omar E. Pol_, Sep 03 2013: (Start)
Illustration of initial terms:
  -----------------------------------
  n  j       Diagram   Composition j
  -----------------------------------
  .               _
  1  1           |_|   1;
  .             _ _
  2  1         |  _|   2,
  2  2         |_|_|   1, 1;
  .           _ _ _
  3  1       |    _|   3,
  3  2       |  _|_|   2, 1,
  3  3       | |  _|   1, 2,
  3  4       |_|_|_|   1, 1, 1;
  .         _ _ _ _
  4  1     |      _|   4,
  4  2     |    _|_|   3, 1,
  4  3     |   |  _|   2, 2,
  4  4     |  _|_|_|   2, 1, 1,
  4  5     | |    _|   1, 3,
  4  6     | |  _|_|   1, 2, 1,
  4  7     | | |  _|   1, 1, 2,
  4  8     |_|_|_|_|   1, 1, 1, 1;
(End)
		

Crossrefs

Lists of compositions of integers: this sequence (reverse lexicographic order; minus one gives A108730), A228351 (reverse colexicographic order - every composition is reversed; minus one gives A163510), A228369 (lexicographic), A228525 (colexicographic), A124734 (length, then lexicographic; minus one gives A124735), A296774 (length, then reverse lexicographic), A337243 (length, then colexicographic), A337259 (length, then reverse colexicographic), A296773 (decreasing length, then lexicographic), A296772 (decreasing length, then reverse lexicographic), A337260 (decreasing length, then colexicographic), A108244 (decreasing length, then reverse colexicographic), also A101211 and A227736 (run lengths of bits).
Cf. row length and row sums for different splittings into rows: A000120, A070939, A001792, A001788.
Cf. lists of partitions of integers, or multisets of integers: A026791 and crosserfs therein, A112798 and crossrefs therein.
See link for additional crossrefs pertaining to standard compositions.
A related ranking of finite sets is A048793/A272020.

Programs

  • Haskell
    a066099 = (!!) a066099_list
    a066099_list = concat a066099_tabf
    a066099_tabf = map a066099_row [1..]
    a066099_row n = reverse $ a228351_row n
    -- (each composition as a row)
    -- Peter Kagey, Aug 25 2016
    
  • Mathematica
    Table[FactorInteger[Apply[Times, Map[Prime, Accumulate @ IntegerDigits[n, 2]]]][[All, -1]], {n, 41}] // Flatten (* Michael De Vlieger, Jul 11 2017 *)
    stc[n_] := Differences[Prepend[Join @@ Position[Reverse[IntegerDigits[n, 2]], 1], 0]] // Reverse;
    Table[stc[n], {n, 0, 20}] // Flatten (* Gus Wiseman, May 19 2020 *)
    Table[Reverse @ LexicographicSort @ Flatten[Permutations /@ Partitions[n], 1], {n, 10}] // Flatten (* Eric W. Weisstein, Jun 26 2023 *)
  • PARI
    arow(n) = {local(v=vector(n),j=0,k=0);
       while(n>0,k++; if(n%2==1,v[j++]=k;k=0);n\=2);
       vector(j,i,v[j-i+1])} \\ returns empty for n=0. - Franklin T. Adams-Watters, Apr 02 2014
    
  • Python
    from itertools import islice
    from itertools import accumulate, count, groupby, islice
    def A066099_gen():
        for i in count(1):
            yield [len(list(g)) for _,g in groupby(accumulate(int(b) for b in bin(i)[2:]))]
    A066099 = list(islice(A066099_gen(), 120))  # Jwalin Bhatt, Feb 28 2025
  • Sage
    def a_row(n): return list(reversed(Compositions(n)))
    flatten([a_row(n) for n in range(1,6)]) # Peter Luschny, May 19 2018
    

Formula

From M. F. Hasler, Oct 12 2020: (Start)
a(n) = A030303(n+1) - A030303(n).
a(A005183(n)) = n; a(A005183(n)+1) = n-1 (n>1); a(A005183(n)+2) = 1. (End)

Extensions

Edited with additional terms by Franklin T. Adams-Watters, Nov 06 2006
0th row removed by Andrey Zabolotskiy, May 19 2018

A000740 Number of 2n-bead balanced binary necklaces of fundamental period 2n, equivalent to reversed complement; also Dirichlet convolution of b_n=2^(n-1) with mu(n); also number of components of Mandelbrot set corresponding to Julia sets with an attractive n-cycle.

Original entry on oeis.org

1, 1, 3, 6, 15, 27, 63, 120, 252, 495, 1023, 2010, 4095, 8127, 16365, 32640, 65535, 130788, 262143, 523770, 1048509, 2096127, 4194303, 8386440, 16777200, 33550335, 67108608, 134209530, 268435455, 536854005, 1073741823, 2147450880
Offset: 1

Views

Author

Keywords

Comments

Also number of compositions of n into relatively prime parts (that is, the gcd of all the parts is 1). Also number of subsets of {1,2,..,n} containing n and consisting of relatively prime numbers. - Vladeta Jovovic, Aug 13 2003
Also number of perfect parity patterns that have exactly n columns (see A118141). - Don Knuth, May 11 2006
a(n) is odd if and only if n is squarefree (Tim Keller). - Emeric Deutsch, Apr 27 2007
a(n) is a multiple of 3 for all n>=3 (see Problem 11161 link). - Emeric Deutsch, Aug 13 2008
Row sums of triangle A143424. - Gary W. Adamson, Aug 14 2008
a(n) is the number of monic irreducible polynomials with nonzero constant coefficient in GF(2)[x] of degree n. - Michel Marcus, Oct 30 2016
a(n) is the number of aperiodic compositions of n, the number of compositions of n with relatively prime parts, and the number of compositions of n with relatively prime run-lengths. - Gus Wiseman, Dec 21 2017

Examples

			For n=4, there are 6 compositions of n into coprime parts: <3,1>, <2,1,1>, <1,3>, <1,2,1>, <1,1,2>, and <1,1,1,1>.
From _Gus Wiseman_, Dec 19 2017: (Start)
The a(6) = 27 aperiodic compositions are:
  (11112), (11121), (11211), (12111), (21111),
  (1113), (1122), (1131), (1221), (1311), (2112), (2211), (3111),
  (114), (123), (132), (141), (213), (231), (312), (321), (411),
  (15), (24), (42), (51),
  (6).
The a(6) = 27 compositions into relatively prime parts are:
  (111111),
  (11112), (11121), (11211), (12111), (21111),
  (1113), (1122), (1131), (1212), (1221), (1311), (2112), (2121), (2211), (3111),
  (114), (123), (132), (141), (213), (231), (312), (321), (411),
  (15), (51).
The a(6) = 27 compositions with relatively prime run-lengths are:
  (11112), (11121), (11211), (12111), (21111),
  (1113), (1131), (1212), (1221), (1311), (2112), (2121), (3111),
  (114), (123), (132), (141), (213), (231), (312), (321), (411),
  (15), (24), (42), (51),
  (6).
(End)
		

References

  • H. O. Peitgen and P. H. Richter, The Beauty of Fractals, Springer-Verlag; contribution by A. Douady, p. 165.
  • N. J. A. Sloane, A Handbook of Integer Sequences, Academic Press, 1973 (includes this sequence).
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Equals A027375/2.
See A056278 for a variant.
First differences of A085945.
Column k=2 of A143325.
Row sums of A101391.

Programs

  • Maple
    with(numtheory): a[1]:=1: a[2]:=1: for n from 3 to 32 do div:=divisors(n): a[n]:=2^(n-1)-sum(a[n/div[j]],j=2..tau(n)) od: seq(a[n],n=1..32); # Emeric Deutsch, Apr 27 2007
    with(numtheory); A000740:=n-> add(mobius(n/d)*2^(d-1), d in divisors(n)); # N. J. A. Sloane, Oct 18 2012
  • Mathematica
    a[n_] := Sum[ MoebiusMu[n/d]*2^(d - 1), {d, Divisors[n]}]; Table[a[n], {n, 1, 32}] (* Jean-François Alcover, Feb 03 2012, after PARI *)
  • PARI
    a(n) = sumdiv(n,d,moebius(n/d)*2^(d-1))
    
  • Python
    from sympy import mobius, divisors
    def a(n): return sum([mobius(n // d) * 2**(d - 1) for d in divisors(n)])
    [a(n) for n in range(1, 101)]  # Indranil Ghosh, Jun 28 2017

Formula

a(n) = Sum_{d|n} mu(n/d)*2^(d-1), Mobius transform of A011782. Furthermore, Sum_{d|n} a(d) = 2^(n-1).
a(n) = A027375(n)/2 = A038199(n)/2.
a(n) = Sum_{k=0..n} A051168(n,k)*k. - Max Alekseyev, Apr 09 2013
Recurrence relation: a(n) = 2^(n-1) - Sum_{d|n,d>1} a(n/d). (Lafayette College Problem Group; see the Maple program and Iglesias eq (6)). - Emeric Deutsch, Apr 27 2007
G.f.: Sum_{k>=1} mu(k)*x^k/(1 - 2*x^k). - Ilya Gutkovskiy, Oct 24 2018
G.f. satisfies Sum_{n>=1} A( (x/(1 + 2*x))^n ) = x. - Paul D. Hanna, Apr 02 2025

Extensions

Connection with Mandelbrot set discovered by Warren D. Smith and proved by Robert Munafo, Feb 06 2000
Ambiguous term a(0) removed by Max Alekseyev, Jan 02 2012

A059966 a(n) = (1/n) * Sum_{ d divides n } mu(n/d) * (2^d - 1).

Original entry on oeis.org

1, 1, 2, 3, 6, 9, 18, 30, 56, 99, 186, 335, 630, 1161, 2182, 4080, 7710, 14532, 27594, 52377, 99858, 190557, 364722, 698870, 1342176, 2580795, 4971008, 9586395, 18512790, 35790267, 69273666, 134215680, 260300986, 505286415, 981706806
Offset: 1

Views

Author

Roland Bacher, Mar 05 2001

Keywords

Comments

Dimensions of the homogeneous parts of the free Lie algebra with one generator in 1,2,3, etc. (Lie analog of the partition numbers).
This sequence is the Lie analog of the partition sequence (which gives the dimensions of the homogeneous polynomials with one generator in each degree) or similarly, of the partitions into distinct (or odd numbers) (which gives the dimensions of the homogeneous parts of the exterior algebra with one generator in each dimension).
The number of cycles of length n of rectangle shapes in the process of repeatedly cutting a square off the end of the rectangle. For example, the one cycle of length 1 is the golden rectangle. - David Pasino (davepasino(AT)yahoo.com), Jan 29 2009
In music, the number of distinct rhythms, at a given tempo, produced by a continuous repetition of measures with identical patterns of 1's and 0's (where 0 means no beat, and 1 means one beat), where each measure allows for n possible beats of uniform character, and when counted under these two conditions: (i) the starting and ending times for the measure are unknown or irrelevant and (ii) identical rhythms that can be produced by using a measure with fewer than n possible beats are excluded from the count. - Richard R. Forberg, Apr 22 2013
Richard R. Forberg's comment does not hold for n=1 because a(1)=1 but there are the two possible rhythms: "0" and "1". - Herbert Kociemba, Oct 24 2016
The comment does hold for n=1 as the rhythm "0" can be produced by using a measure of 0 beats and so is properly excluded from a(1)=1 by condition (ii) of the comment. - Travis Scott, May 28 2022
a(n) is also the number of Lyndon compositions (aperiodic necklaces of positive integers) with sum n. - Gus Wiseman, Dec 19 2017
Mobius transform of A008965. - Jianing Song, Nov 13 2021
a(n) is the number of cycles of length n for the map x->1 - abs(2*x-1) applied on rationals 0Michel Marcus, Jul 16 2025

Examples

			a(4)=3: the 3 elements [a,c], [a[a,b]] and d form a basis of all homogeneous elements of degree 4 in the free Lie algebra with generators a of degree 1, b of degree 2, c of degree 3 and d of degree 4.
From _Gus Wiseman_, Dec 19 2017: (Start)
The sequence of Lyndon compositions organized by sum begins:
  (1),
  (2),
  (3),(12),
  (4),(13),(112),
  (5),(14),(23),(113),(122),(1112),
  (6),(15),(24),(114),(132),(123),(1113),(1122),(11112),
  (7),(16),(25),(115),(34),(142),(124),(1114),(133),(223),(1213),(1132),(1123),(11113),(1222),(11212),(11122),(111112). (End)
		

References

  • C. Reutenauer, Free Lie algebras, Clarendon press, Oxford (1993).

Crossrefs

Apart from initial terms, same as A001037.

Programs

  • Haskell
    a059966 n = sum (map (\x -> a008683 (n `div` x) * a000225 x)
                         [d | d <- [1..n], mod n d == 0]) `div` n
    -- Reinhard Zumkeller, Nov 18 2011
    
  • Mathematica
    Table[1/n Apply[Plus, Map[(MoebiusMu[n/# ](2^# - 1)) &, Divisors[n]]], {n, 20}]
    (* Second program: *)
    Table[(1/n) DivisorSum[n, MoebiusMu[n/#] (2^# - 1) &], {n, 35}] (* Michael De Vlieger, Jul 22 2019 *)
  • Python
    from sympy import mobius, divisors
    def A059966(n): return sum(mobius(n//d)*(2**d-1) for d in divisors(n,generator=True))//n # Chai Wah Wu, Feb 03 2022

Formula

G.f.: Product_{n>0} (1-q^n)^a(n) = 1-q-q^2-q^3-q^4-... = 2-1/(1-q).
Inverse Euler transform of A011782. - Alois P. Heinz, Jun 23 2018
G.f.: Sum_{k>=1} mu(k)*log((1 - x^k)/(1 - 2*x^k))/k. - Ilya Gutkovskiy, May 19 2019
a(n) ~ 2^n / n. - Vaclav Kotesovec, Aug 10 2019
Dirichlet g.f.: f(s+1)/zeta(s+1) - 1, where f(s) = Sum_{n>=1} 2^n/n^s. - Jianing Song, Nov 13 2021

Extensions

Explicit formula from Paul D. Hanna, Apr 15 2002
Description corrected by Axel Kleinschmidt, Sep 15 2002

A228351 Triangle read by rows in which row n lists the compositions (ordered partitions) of n (see Comments lines for definition).

Original entry on oeis.org

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

Views

Author

Omar E. Pol, Aug 30 2013

Keywords

Comments

The representation of the compositions (for fixed n) is as lists of parts, the order between individual compositions (for the same n) is (list-)reversed co-lexicographic. - Joerg Arndt, Sep 02 2013
Dropping the "(list-)reversed" in the comment above gives A228525.
The equivalent sequence for partitions is A026792.
This sequence lists (without repetitions) all finite compositions, in such a way that, if [P_1, ..., P_r] denotes the composition occupying the n-th position in the list, then (((2*n/2^(P_1)-1)/2^(P_2)-1)/...)/2^(P_r)-1 = 0. - Lorenzo Sauras Altuzarra, Jan 22 2020
The k-th composition in the list is obtained by taking the set of positions of 1's in the reversed binary expansion of k, prepending 0, and taking first differences. Reversing again gives A066099, which is described as the standard ordering. Both sequences define a bijective correspondence between nonnegative integers and integer compositions. - Gus Wiseman, Apr 01 2020
It follows from the previous comment that A000120(k) is the length of the k-th composition that is listed by this sequence (recall that A000120(k) is the number of 1's in the binary expansion of k). - Lorenzo Sauras Altuzarra, Sep 29 2020

Examples

			Illustration of initial terms:
-----------------------------------
n  j     Diagram     Composition j
-----------------------------------
.         _
1  1     |_|         1;
.         _ _
2  1     |_  |       2,
2  2     |_|_|       1, 1;
.         _ _ _
3  1     |_    |     3,
3  2     |_|_  |     1, 2,
3  3     |_  | |     2, 1,
3  4     |_|_|_|     1, 1, 1;
.         _ _ _ _
4  1     |_      |   4,
4  2     |_|_    |   1, 3,
4  3     |_  |   |   2, 2,
4  4     |_|_|_  |   1, 1, 2,
4  5     |_    | |   3, 1,
4  6     |_|_  | |   1, 2, 1,
4  7     |_  | | |   2, 1, 1,
4  8     |_|_|_|_|   1, 1, 1, 1;
.
Triangle begins:
[1];
[2],[1,1];
[3],[1,2],[2,1],[1,1,1];
[4],[1,3],[2,2],[1,1,2],[3,1],[1,2,1],[2,1,1],[1,1,1,1];
[5],[1,4],[2,3],[1,1,3],[3,2],[1,2,2],[2,1,2],[1,1,1,2],[4,1],[1,3,1],[2,2,1],[1,1,2,1],[3,1,1],[1,2,1,1],[2,1,1,1],[1,1,1,1,1];
...
For example [1,2] occupies the 5th position in the corresponding list of compositions and indeed (2*5/2^1-1)/2^2-1 = 0. - _Lorenzo Sauras Altuzarra_, Jan 22 2020
12 --binary expansion--> [1,1,0,0] --reverse--> [0,0,1,1] --positions of 1's--> [3,4] --prepend 0--> [0,3,4] --first differences--> [3,1]. - _Lorenzo Sauras Altuzarra_, Sep 29 2020
		

Crossrefs

Row n has length A001792(n-1). Row sums give A001787, n >= 1.
Cf. A000120 (binary weight), A001511, A006519, A011782, A026792, A065120.
A related ranking of finite sets is A048793/A272020.
All of the following consider the k-th row to be the k-th composition, ignoring the coarser grouping by sum.
- Indices of weakly increasing rows are A114994.
- Indices of weakly decreasing rows are A225620.
- Indices of strictly decreasing rows are A333255.
- Indices of strictly increasing rows are A333256.
- Indices of reversed interval rows A164894.
- Indices of interval rows are A246534.
- Indices of strict rows are A233564.
- Indices of constant rows are A272919.
- Indices of anti-run rows are A333489.
- Row k has A124767(k) runs and A333381(k) anti-runs.
- Row k has GCD A326674(k) and LCM A333226(k).
- Row k has Heinz number A333219(k).
Equals A163510+1, termwise.
Cf. A124734 (increasing length, then lexicographic).
Cf. A296774 (increasing length, then reverse lexicographic).
Cf. A337243 (increasing length, then colexicographic).
Cf. A337259 (increasing length, then reverse colexicographic).
Cf. A296773 (decreasing length, then lexicographic).
Cf. A296772 (decreasing length, then reverse lexicographic).
Cf. A337260 (decreasing length, then colexicographic).
Cf. A108244 (decreasing length, then reverse colexicographic).
Cf. A228369 (lexicographic).
Cf. A066099 (reverse lexicographic).
Cf. A228525 (colexicographic).

Programs

  • Haskell
    a228351 n = a228351_list !! (n - 1)
    a228351_list = concatMap a228351_row [1..]
    a228351_row 0 = []
    a228351_row n = a001511 n : a228351_row (n `div` 2^(a001511 n))
    -- Peter Kagey, Jun 27 2016
    
  • Maple
    # Program computing the sequence:
    A228351 := proc(n) local c, k, L, N: L, N := [], [seq(2*r, r = 1 .. n)]: for k in N do c := 0: while k != 0 do if gcd(k, 2) = 2 then k := k/2: c := c+1: else L := [op(L), op(c)]: k := k-1: c := 0: fi: od: od: L[n]: end: # Lorenzo Sauras Altuzarra, Jan 22 2020
    # Program computing the list of compositions:
    List := proc(n) local c, k, L, M, N: L, M, N := [], [], [seq(2*r, r = 1 .. 2^n-1)]: for k in N do c := 0: while k != 0 do if gcd(k, 2) = 2 then k := k/2: c := c+1: else L := [op(L), c]: k := k-1: c := 0: fi: od: M := [op(M), L]: L := []: od: M: end: # Lorenzo Sauras Altuzarra, Jan 22 2020
  • Mathematica
    bpe[n_]:=Join@@Position[Reverse[IntegerDigits[n,2]],1];
    Table[Differences[Prepend[bpe[n],0]],{n,0,30}] (* Gus Wiseman, Apr 01 2020 *)
  • Python
    from itertools import count, islice
    def A228351_gen(): # generator of terms
        for n in count(1):
            k = n
            while k:
                yield (s:=(~k&k-1).bit_length()+1)
                k >>= s
    A228351_list = list(islice(A228351_gen(),30)) # Chai Wah Wu, Jul 17 2023

A026791 Triangle in which n-th row lists juxtaposed lexicographically ordered partitions of n; e.g., the partitions of 3 (1+1+1,1+2,3) appear as 1,1,1,1,2,3 in row 3.

Original entry on oeis.org

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

Views

Author

Keywords

Comments

Differs from A080576 in a(18): Here, (...,1+3,2+2,4), there (...,2+2,1+3,4).
The representation of the partitions (for fixed n) is as (weakly) increasing lists of parts, the order between individual partitions (for the same n) is lexicographic (see example). - Joerg Arndt, Sep 03 2013
The equivalent sequence for compositions (ordered partitions) is A228369. - Omar E. Pol, Oct 19 2019

Examples

			First six rows are:
[[1]];
[[1, 1], [2]];
[[1, 1, 1], [1, 2], [3]];
[[1, 1, 1, 1], [1, 1, 2], [1, 3], [2, 2], [4]];
[[1, 1, 1, 1, 1], [1, 1, 1, 2], [1, 1, 3], [1, 2, 2], [1, 4], [2, 3], [5]];
[[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 2], [1, 1, 1, 3], [1, 1, 2, 2], [1, 1, 4], [1, 2, 3], [1, 5], [2, 2, 2], [2, 4], [3, 3], [6]];
...
From _Omar E. Pol_, Sep 03 2013: (Start)
Illustration of initial terms:
----------------------------------
.                     Ordered
n  j      Diagram     partition j
----------------------------------
.               _
1  1           |_|    1;
.             _ _
2  1         | |_|    1, 1,
2  2         |_ _|    2;
.           _ _ _
3  1       | | |_|    1, 1, 1,
3  2       | |_ _|    1, 2,
3  3       |_ _ _|    3;
.         _ _ _ _
4  1     | | | |_|    1, 1, 1, 1,
4  2     | | |_ _|    1, 1, 2,
4  3     | |_ _ _|    1, 3,
4  4     |   |_ _|    2, 2,
4  5     |_ _ _ _|    4;
...
(End)
		

Crossrefs

Row lengths are given in A006128.
Partition lengths are in A193173.
Row lengths are A000041.
Partition sums are A036042.
Partition minima are A196931.
Partition maxima are A194546.
The reflected version is A211992.
The length-sensitive version (sum/length/lex) is A036036.
The colexicographic version (sum/colex) is A080576.
The version for non-reversed partitions is A193073.
Compositions under the same ordering (sum/lex) are A228369.
The reverse-lexicographic version (sum/revlex) is A228531.
The Heinz numbers of these partitions are A334437.

Programs

  • Maple
    T:= proc(n) local b, ll;
          b:= proc(n,l)
                if n=0 then ll:= ll, l[]
              else seq(b(n-i, [l[], i]), i=`if`(l=[],1,l[-1])..n)
                fi
              end;
          ll:= NULL; b(n, []); ll
        end:
    seq(T(n), n=1..8);  # Alois P. Heinz, Jul 16 2011
  • Mathematica
    T[n0_] := Module[{b, ll}, b[n_, l_] := If[n == 0, ll = Join[ll, l], Table[ b[n - i, Append[l, i]], {i, If[l == {}, 1, l[[-1]]], n}]]; ll = {}; b[n0, {}]; ll]; Table[T[n], {n, 1, 8}] // Flatten (* Jean-François Alcover, Aug 05 2015, after Alois P. Heinz *)
    Table[DeleteCases[Sort@PadRight[Reverse /@ IntegerPartitions[n]], x_ /; x == 0, 2], {n, 7}] // Flatten (* Robert Price, May 18 2020 *)
  • Python
    t = [[[]]]
    for n in range(1, 10):
        p = []
        for minp in range(1, n):
            p += [[minp] + pp for pp in t[n-minp] if min(pp) >= minp]
        t.append(p + [[n]])
    print(t)
    # Andrey Zabolotskiy, Oct 18 2019

A228525 Triangle read by rows in which row n lists the compositions (ordered partitions) of n in colexicographic order.

Original entry on oeis.org

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

Views

Author

Omar E. Pol, Aug 24 2013

Keywords

Comments

The representation of the compositions (for fixed n) is as lists of parts, the order between individual compositions (for the same n) is co-lexicographic. [Joerg Arndt, Sep 02 2013]
The equivalent sequence for partitions is A211992.
Row n has length A001792(n-1).
Row sums give A001787, n >= 1.

Examples

			Illustration of initial terms:
---------------------------------
n  j     Diagram     Composition
---------------------------------
.         _
1  1     |_|         1;
.         _ _
2  1     |_| |       1, 1,
2  2     |_ _|       2;
.         _ _ _
3  1     |_| | |     1, 1, 1,
3  2     |_ _| |     2, 1,
3  3     |_|   |     1, 2,
3  4     |_ _ _|     3;
.         _ _ _ _
4  1     |_| | | |   1, 1, 1, 1,
4  2     |_ _| | |   2, 1, 1,
4  3     |_|   | |   1, 2, 1,
4  4     |_ _ _| |   3, 1,
4  5     |_| |   |   1, 1, 2,
4  6     |_ _|   |   2, 2,
4  7     |_|     |   1, 3,
4  8     |_ _ _ _|   4;
.
Triangle begins:
[1];
[1,1],[2];
[1,1,1],[2,1],[1,2],[3];
[1,1,1,1],[2,1,1],[1,2,1],[3,1],[1,1,2],[2,2],[1,3],[4];
[1,1,1,1,1],[2,1,1,1],[1,2,1,1],[3,1,1],[1,1,2,1],[2,2,1],[1,3,1],[4,1],[1,1,1,2],[2,1,2],[1,2,2],[3,2],[1,1,3],[2,3],[1,4],[5];
		

Crossrefs

Programs

  • PARI
    gen_comp(n)=
    {  /* Generate compositions of n as lists of parts (order is lex): */
        my(ct = 0);
        my(m, z, pt);
        \\ init:
        my( a = vector(n, j, 1) );
        m = n;
        while ( 1,
            ct += 1;
            pt = vector(m, j, a[j]);
    \\        /* for A228369  print composition: */
    \\        for (j=1, m, print1(pt[j],", ") );
            /* for A228525 print reversed (order is colex): */
            forstep (j=m, 1, -1, print1(pt[j],", ") );
            if ( m<=1,  return(ct) );  \\ current is last
            a[m-1] += 1;
            z = a[m] - 2;
            a[m] = 1;
            m += z;
        );
        return(ct);
    }
    for(n=1, 12, gen_comp(n) );
    \\ Joerg Arndt, Sep 02 2013

A296774 Triangle read by rows in which row n lists the compositions of n ordered first by length and then reverse-lexicographically.

Original entry on oeis.org

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

Views

Author

Gus Wiseman, Dec 20 2017

Keywords

Examples

			Triangle of compositions begins:
(1),
(2),(11),
(3),(21),(12),(111),
(4),(31),(22),(13),(211),(121),(112),(1111),
(5),(41),(32),(23),(14),(311),(221),(212),(131),(122),(113),(2111),(1211),(1121),(1112),(11111).
		

Crossrefs

Programs

  • Mathematica
    Table[Sort[Join@@Permutations/@IntegerPartitions[n],Or[Length[#1]
    				

A296302 Number of aperiodic compositions of n with relatively prime parts. Number of compositions of n with relatively prime parts and relatively prime run-lengths.

Original entry on oeis.org

1, 0, 2, 5, 14, 24, 62, 114, 249, 480, 1022, 1978, 4094, 8064, 16348, 32520, 65534, 130512, 262142, 523270, 1048444, 2095104, 4194302, 8384316, 16777185, 33546240, 67108356, 134201398, 268435454, 536837136, 1073741822, 2147418240, 4294965244, 8589803520
Offset: 1

Views

Author

Gus Wiseman, Dec 11 2017

Keywords

Examples

			The a(6) = 24 aperiodic compositions with relatively prime parts are:
(15), (51),
(114), (123), (132), (141), (213), (231), (312), (321), (411),
(1113), (1122), (1131), (1221), (1311), (2112), (2211), (3111),
(11112), (11121), (11211), (12111), (21111).
		

Crossrefs

Programs

  • Mathematica
    Table[DivisorSum[n,Function[d,MoebiusMu[n/d]*DivisorSum[d,MoebiusMu[#]*2^(d/#-1)&]]],{n,20}]

Formula

a = mu * mu * c, where * is Dirichlet convolution and c(n) = 2^(n-1).

A296372 Triangle read by rows: T(n,k) is the number of normal sequences of length n whose standard factorization into Lyndon words (aperiodic necklaces) has k factors.

Original entry on oeis.org

1, 1, 2, 4, 5, 4, 18, 31, 18, 8, 108, 208, 153, 56, 16, 778, 1700, 1397, 616, 160, 32, 6756, 15980, 14668, 7197, 2196, 432, 64, 68220, 172326, 171976, 93293, 31564, 7208, 1120, 128
Offset: 1

Views

Author

Gus Wiseman, Dec 11 2017

Keywords

Comments

A finite sequence is normal if its union is an initial interval of positive integers.

Examples

			The T(3,2) = 5 normal sequences are {2,1,2}, {1,2,1}, {2,1,3}, {2,3,1}, {3,1,2}.
Triangle begins:
     1;
     1,     2;
     4,     5,     4;
    18,    31,    18,     8;
   108,   208,   153,    56,    16;
   778,  1700,  1397,   616,   160,    32;
  6756, 15980, 14668,  7197,  2196,   432,    64;
		

Crossrefs

Programs

  • Mathematica
    neckQ[q_]:=Array[OrderedQ[{q,RotateRight[q,#]}]&,Length[q]-1,1,And];
    aperQ[q_]:=UnsameQ@@Table[RotateRight[q,k],{k,Length[q]}];
    qit[q_]:=If[#===Length[q],{q},Prepend[qit[Drop[q,#]],Take[q,#]]]&[Max@@Select[Range[Length[q]],neckQ[Take[q,#]]&&aperQ[Take[q,#]]&]];
    allnorm[n_]:=Function[s,Array[Count[s,y_/;y<=#]+1&,n]]/@Subsets[Range[n-1]+1];
    Table[Length[Select[Join@@Permutations/@allnorm[n],Length[qit[#]]===k&]],{n,5},{k,n}]
  • PARI
    \\ here U(n,k) is A074650(n,k).
    EulerMT(u)={my(n=#u, p=x*Ser(u), vars=variables(p)); Vec(exp( sum(i=1, n, substvec(p + O(x*x^(n\i)), vars, apply(v->v^i,vars))/i ))-1)}
    U(n,k)={sumdiv(n, d, moebius(n/d) * k^d)/n}
    A(n)={[Vecrev(p/y) | p<-sum(k=1, n, EulerMT(vector(n, n, y*U(n,k)))*sum(j=k, n, (-1)^(k-j)*binomial(j,k)))]}
    { my(T=A(10)); for(n=1, #T, print(T[n])) } \\ Andrew Howroyd, Dec 08 2018

Extensions

Example and program corrected by Gus Wiseman, Dec 08 2018

A281013 Tetrangle T(n,k,i) = i-th part of k-th prime composition of n.

Original entry on oeis.org

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

Views

Author

Gus Wiseman, Jan 12 2017

Keywords

Comments

The *-product of two or more finite sequences is defined to be the lexicographically minimal sequence obtainable by shuffling them together. Every finite positive integer sequence has a unique *-factorization using prime compositions P = {(1), (2), (21), (3), (211), ...}. See A060223 and A228369 for details.
These are co-Lyndon compositions, ordered first by sum and then lexicographically. - Gus Wiseman, Nov 15 2019

Examples

			The prime factorization of (1, 1, 4, 2, 3, 1, 5, 5) is: (11423155) = (1)*(1)*(5)*(5)*(4231). The prime factorizations of the initial terms of A000002 are:
             (1) = (1)
            (12) = (1)*(2)
           (122) = (1)*(2)*(2)
          (1221) = (1)*(221)
         (12211) = (1)*(2211)
        (122112) = (1)*(2)*(2211)
       (1221121) = (1)*(221121)
      (12211212) = (1)*(2)*(221121)
     (122112122) = (1)*(2)*(2)*(221121)
    (1221121221) = (1)*(221)*(221121)
   (12211212212) = (1)*(2)*(221)*(221121)
  (122112122122) = (1)*(2)*(2)*(221)*(221121).
Read as a sequence:
(1), (2), (21), (3), (211), (31), (4), (2111), (221), (311), (32), (41), (5).
Read as a triangle:
(1)
(2)
(21), (3)
(211), (31), (4)
(2111), (221), (311), (32), (41), (5).
Read as a sequence of triangles:
1    2    2 1    2 1 1    2 1 1 1    2 1 1 1 1    2 1 1 1 1 1
          3      3 1      2 2 1      2 2 1 1      2 1 2 1 1
                 4        3 1 1      3 1 1 1      2 2 1 1 1
                          3 2        3 1 2        2 2 2 1
                          4 1        3 2 1        3 1 1 1 1
                          5          4 1 1        3 1 1 2
                                     4 2          3 1 2 1
                                     5 1          3 2 1 1
                                     6            3 2 2
                                                  3 3 1
                                                  4 1 1 1
                                                  4 1 2
                                                  4 2 1
                                                  4 3
                                                  5 1 1
                                                  5 2
                                                  6 1
                                                  7.
		

Crossrefs

The binary version is A329318.
The binary non-"co" version is A102659.
A sequence listing all Lyndon compositions is A294859.
Numbers whose binary expansion is co-Lyndon are A328596.
Numbers whose binary expansion is co-Lyndon are A275692.
Binary Lyndon words are A001037.
Lyndon compositions are A059966.
Normal Lyndon words are A060223.

Programs

  • Mathematica
    colynQ[q_]:=Array[Union[{RotateRight[q,#],q}]=={RotateRight[q,#],q}&,Length[q]-1,1,And];
    lexsort[f_,c_]:=OrderedQ[PadRight[{f,c}]];
    Table[Sort[Select[Join@@Permutations/@IntegerPartitions[n],colynQ],lexsort],{n,5}] (* Gus Wiseman, Nov 15 2019 *)

Formula

Row lengths are A059966(n) = number of prime compositions of n.
Showing 1-10 of 35 results. Next