OFFSET
0,7
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.
FORMULA
EXAMPLE
Composition number 741 in standard order is (2,1,1,3,2,1), so a(741) = 1 + 3 + 1 = 5.
MATHEMATICA
stc[n_]:=Differences[Prepend[Join@@Position[Reverse[IntegerDigits[n, 2]], 1], 0]]//Reverse;
Table[Total[Last/@Partition[Append[stc[n], 0], 2]], {n, 0, 100}]
CROSSREFS
Including odd-indexed parts gives A029837.
Subtracting from the odd version gives A124754.
Positions of zeros are A131577.
The odd-indexed version is A209281(n+1).
A011782 counts compositions.
A097805 counts compositions by alternating (or reverse-alternating) sum.
A345197 counts compositions by sum, length, and alternating sum.
KEYWORD
nonn
AUTHOR
Gus Wiseman, Aug 01 2021
STATUS
approved