login
A394091
Greatest partial alternating sum of the n-th composition in standard order (row n of A066099). Row-maxima of A391983.
2
0, 1, 2, 1, 3, 2, 1, 1, 4, 3, 2, 2, 2, 1, 2, 1, 5, 4, 3, 3, 2, 2, 3, 2, 3, 2, 1, 1, 3, 2, 1, 1, 6, 5, 4, 4, 3, 3, 4, 3, 2, 2, 2, 2, 4, 3, 2, 2, 4, 3, 2, 2, 2, 1, 2, 1, 4, 3, 2, 2, 2, 1, 2, 1, 7, 6, 5, 5, 4, 4, 5, 4, 3, 3, 3, 3, 5, 4, 3, 3, 3, 2, 2, 2, 3, 2, 2
OFFSET
0,3
COMMENTS
After the first term, all terms are positive.
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.
The partial alternating sums of a finite sequence q are given by pas(q)_j = Sum_{i=1..j} (-1)^(i+j) * q_i. For example, pas((a,b,c,d,e))_3 = a - b + c.
FORMULA
a(2^(n-1)) = n.
EXAMPLE
The 9th composition in standard order is (3,1), with partial alternating sums (0,3,-2), so a(9) = 3.
MATHEMATICA
stc[n_]:=Differences[Prepend[Join@@Position[Reverse[IntegerDigits[n, 2]], 1], 0]]//Reverse;
pas[y_]:=Table[Sum[(-1)^(i+j)*y[[i]], {i, j}], {j, 0, Length[y]}];
Table[Max@@pas[stc[n]], {n, 0, 100}]
CROSSREFS
Positions of ones appear to be A033053.
For reversed prime indices we appear to have A061395, min A394095 (trimmed A394096).
Without alternating sums see A333766, min A333768, first A065120, last A001511.
For last instead of maximum we have A344618.
For run-lengths instead of partial alternating sums we have A357137.
Row-maxima of A391983, reverse A391984, non-singleton case A391981 or A392374.
For minimum instead of maximum we have A394092, trimmed A392713.
The version for prime indices is A394093, min A394094.
All of the following pertain to compositions in standard order (A066099):
- Length is A000120.
- Sum is A029837.
- Weakly decreasing compositions are A114994, increasing A225620.
- Runs are counted by A124767.
- Constant compositions are A272919.
- Strictly decreasing compositions are A333255, increasing A333256.
- First differences are A358133.
- Partial sums are A358134.
- First sums are A390432, row ranks A390568.
A003242 counts anti-run compositions, ranks A333489.
A005811 counts runs in binary expansion.
A011782 counts compositions.
A097805 counts compositions by alternating sum.
Sequence in context: A392706 A065120 A176206 * A232890 A300441 A375378
KEYWORD
nonn
AUTHOR
Gus Wiseman, Mar 15 2026
STATUS
approved