OFFSET
0,4
COMMENTS
The first sums of a nonempty sequence (a, b, c, d, ...) are (a+b, b+c, c+d, ...).
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 300-th composition in standard order is (3,2,1,3), with first sums (5,3,4), with sum 12, so a(300) = 12.
MATHEMATICA
stc[n_]:=Differences[Prepend[Join @@ Position[Reverse[IntegerDigits[n, 2]], 1], 0]]//Reverse;
firsums[c_]:=Table[c[[i]]+c[[i+1]], {i, Length[c]-1}];
Table[Total[firsums[stc[n]]], {n, 0, 100}]
CROSSREFS
KEYWORD
nonn
AUTHOR
Gus Wiseman, Nov 26 2025
STATUS
approved
