OFFSET
1,3
COMMENTS
A composition of n is a finite sequence of positive integers summing to n. 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 alternating sum of a sequence (y_1,...,y_k) is Sum_i (-1)^(i-1) y_i.
LINKS
EXAMPLE
The sequence together with the corresponding compositions begins:
0: ()
1: (1)
9: (3,1)
12: (1,3)
19: (3,1,1)
22: (2,1,2)
28: (1,1,3)
34: (4,2)
40: (2,4)
69: (4,2,1)
74: (3,2,2)
84: (2,2,3)
97: (1,5,1)
104: (1,2,4)
132: (5,3)
135: (5,1,1,1)
141: (4,1,2,1)
MATHEMATICA
stc[n_]:=Differences[Prepend[Join @@ Position[Reverse[IntegerDigits[n, 2]], 1], 0]]//Reverse;
ats[y_]:=Sum[(-1)^(i-1)*y[[i]], {i, Length[y]}];
Select[Range[0, 100], Length[stc[#]]==Abs[ats[stc[#]]]&]
CROSSREFS
KEYWORD
nonn
AUTHOR
Gus Wiseman, Sep 28 2022
STATUS
approved