OFFSET
0,3
COMMENTS
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.
Also the sum of 0-based partial alternating sums of the reversed n-th composition in standard order. Here, the k-based partial alternating sums of a finite sequence q are given by pas(q,k)_j = (-1)^j * k + Sum_{i=1..j} (-1)^(i+j) * q_i. This is a signed version of the partial sums transformation, inverse to the "first sums" transformation.
For example, the 0-based partial alternating sums of q = (a,b,c,d,e) are:
pas(q,0)_1 = a
pas(q,0)_2 = -a + b
pas(q,0)_3 = a - b + c
pas(q,0)_4 = -a + b - c + d
pas(q,0)_5 = a - b + c - d + e
EXAMPLE
The 300th composition in standard order is (3,2,1,3), reversed (3,1,2,3), with odd-indexed parts (3,2), so a(300) = 5.
MATHEMATICA
stc[n_]:=Differences[Prepend[Join @@ Position[Reverse[IntegerDigits[n, 2]], 1], 0]]//Reverse;
go[c_]:=Sum[If[OddQ[i], c[[i]], 0], {i, Length[c]}];
Table[go[Reverse[stc[n]]], {n, 0, 100}]
CROSSREFS
KEYWORD
nonn
AUTHOR
Gus Wiseman, Jan 14 2026
STATUS
approved
