login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A228351 Triangle read by rows in which row n lists the compositions (ordered partitions) of n (see Comments lines for definition). 118

%I #81 Jul 17 2023 13:18:10

%S 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,

%T 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,

%U 2,1,1,2,1,1,1,1,1,1,1,1,6,1,5,2,4,1,1,4

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

%C 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

%C Dropping the "(list-)reversed" in the comment above gives A228525.

%C The equivalent sequence for partitions is A026792.

%C 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

%C 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

%C 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

%H Peter Kagey, <a href="/A228351/b228351.txt">Table of n, a(n) for n = 1..10000</a>

%H Mikhail Kurkov, <a href="/A228351/a228351.txt">Comments on A228351</a>

%H <a href="/index/Com#comp">Index entries for sequences that are related to compositions</a>

%e Illustration of initial terms:

%e -----------------------------------

%e n j Diagram Composition j

%e -----------------------------------

%e . _

%e 1 1 |_| 1;

%e . _ _

%e 2 1 |_ | 2,

%e 2 2 |_|_| 1, 1;

%e . _ _ _

%e 3 1 |_ | 3,

%e 3 2 |_|_ | 1, 2,

%e 3 3 |_ | | 2, 1,

%e 3 4 |_|_|_| 1, 1, 1;

%e . _ _ _ _

%e 4 1 |_ | 4,

%e 4 2 |_|_ | 1, 3,

%e 4 3 |_ | | 2, 2,

%e 4 4 |_|_|_ | 1, 1, 2,

%e 4 5 |_ | | 3, 1,

%e 4 6 |_|_ | | 1, 2, 1,

%e 4 7 |_ | | | 2, 1, 1,

%e 4 8 |_|_|_|_| 1, 1, 1, 1;

%e .

%e Triangle begins:

%e [1];

%e [2],[1,1];

%e [3],[1,2],[2,1],[1,1,1];

%e [4],[1,3],[2,2],[1,1,2],[3,1],[1,2,1],[2,1,1],[1,1,1,1];

%e [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];

%e ...

%e 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

%e 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

%p # Program computing the sequence:

%p 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

%p # Program computing the list of compositions:

%p 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

%t bpe[n_]:=Join@@Position[Reverse[IntegerDigits[n,2]],1];

%t Table[Differences[Prepend[bpe[n],0]],{n,0,30}] (* _Gus Wiseman_, Apr 01 2020 *)

%o (Haskell)

%o a228351 n = a228351_list !! (n - 1)

%o a228351_list = concatMap a228351_row [1..]

%o a228351_row 0 = []

%o a228351_row n = a001511 n : a228351_row (n `div` 2^(a001511 n))

%o -- _Peter Kagey_, Jun 27 2016

%o (Python)

%o from itertools import count, islice

%o def A228351_gen(): # generator of terms

%o for n in count(1):

%o k = n

%o while k:

%o yield (s:=(~k&k-1).bit_length()+1)

%o k >>= s

%o A228351_list = list(islice(A228351_gen(),30)) # _Chai Wah Wu_, Jul 17 2023

%Y Row n has length A001792(n-1). Row sums give A001787, n >= 1.

%Y Cf. A000120 (binary weight), A001511, A006519, A011782, A026792, A065120.

%Y A related ranking of finite sets is A048793/A272020.

%Y All of the following consider the k-th row to be the k-th composition, ignoring the coarser grouping by sum.

%Y - Indices of weakly increasing rows are A114994.

%Y - Indices of weakly decreasing rows are A225620.

%Y - Indices of strictly decreasing rows are A333255.

%Y - Indices of strictly increasing rows are A333256.

%Y - Indices of reversed interval rows A164894.

%Y - Indices of interval rows are A246534.

%Y - Indices of strict rows are A233564.

%Y - Indices of constant rows are A272919.

%Y - Indices of anti-run rows are A333489.

%Y - Row k has A124767(k) runs and A333381(k) anti-runs.

%Y - Row k has GCD A326674(k) and LCM A333226(k).

%Y - Row k has Heinz number A333219(k).

%Y Cf. A000120, A029931, A035327, A070939, A233249, A333217, A333218, A333220, A333227, A333627, A333628.

%Y Equals A163510+1, termwise.

%Y Cf. A124734 (increasing length, then lexicographic).

%Y Cf. A296774 (increasing length, then reverse lexicographic).

%Y Cf. A337243 (increasing length, then colexicographic).

%Y Cf. A337259 (increasing length, then reverse colexicographic).

%Y Cf. A296773 (decreasing length, then lexicographic).

%Y Cf. A296772 (decreasing length, then reverse lexicographic).

%Y Cf. A337260 (decreasing length, then colexicographic).

%Y Cf. A108244 (decreasing length, then reverse colexicographic).

%Y Cf. A228369 (lexicographic).

%Y Cf. A066099 (reverse lexicographic).

%Y Cf. A228525 (colexicographic).

%K nonn,tabf

%O 1,2

%A _Omar E. Pol_, Aug 30 2013

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 18 06:24 EDT 2024. Contains 371769 sequences. (Running on oeis4.)