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.
LINKS
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 last instead of maximum we have A344618.
For run-lengths instead of partial alternating sums we have A357137.
All of the following pertain to compositions in standard order (A066099):
- Length is A000120.
- Sum is A029837.
- Runs are counted by A124767.
- Constant compositions are A272919.
- First differences are A358133.
- Partial sums are A358134.
A005811 counts runs in binary expansion.
A011782 counts compositions.
A097805 counts compositions by alternating sum.
KEYWORD
nonn
AUTHOR
Gus Wiseman, Mar 15 2026
STATUS
approved
