OFFSET
0,4
COMMENTS
We define the Lyndon product of two or more finite sequences to be the lexicographically maximal sequence obtainable by shuffling the sequences together. For example, the Lyndon product of (231) with (213) is (232131), the product of (221) with (213) is (222131), and the product of (122) with (2121) is (2122121). A Lyndon word is a finite sequence that is prime with respect to the Lyndon product. Every finite sequence has a unique (orderless) factorization into Lyndon words, and if these factors are arranged in lexicographically decreasing order, their concatenation is equal to their Lyndon product. For example, (1001) has sorted Lyndon factorization (001)(1).
The k-th composition in standard order (graded reverse-lexicographic, A066099) 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 gives a bijective correspondence between nonnegative integers and integer compositions.
EXAMPLE
The 12345th composition is (1,7,1,1,3,1), with reverse (1,3,1,1,7,1), with Lyndon factorization ((1),(1,3),(1,1,7)), so a(12345) = 3.
MATHEMATICA
stc[n_]:=Differences[Prepend[Join@@Position[Reverse[IntegerDigits[n, 2]], 1], 0]]//Reverse;
lynQ[q_]:=Length[q]==0||Array[Union[{q, RotateRight[q, #]}]=={q, RotateRight[q, #]}&, Length[q]-1, 1, And];
lynfac[q_]:=If[Length[q]==0, {}, Function[i, Prepend[lynfac[Drop[q, i]], Take[q, i]]][Last[Select[Range[Length[q]], lynQ[Take[q, #]]&]]]];
Table[Length[lynfac[Reverse[stc[n]]]], {n, 0, 100}]
CROSSREFS
The non-reversed version is A329312.
The version for binary indices is A329313 (also the "co-" version).
Positions of 1's are A334265 (reversed Lyndon words).
All of the following pertain to compositions in standard order (A066099):
- Length is A000120.
- Necklaces are A065609.
- Sum is A070939.
- Reverse is A228351 (triangle).
- Strict compositions are A233564.
- Constant compositions are A272919.
- Lyndon words are A275692.
- Co-Lyndon words are A326774.
- Reversed co-Lyndon words are A328596.
- Aperiodic compositions are A328594.
- Distinct rotations are counted by A333632.
- Lyndon factorizations are counted by A333940.
- Length of co-Lyndon factorization is A334029.
KEYWORD
nonn
AUTHOR
Gus Wiseman, Apr 25 2020
STATUS
approved