OFFSET
1,2
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.
The alternating sum of a sequence (y_1,...,y_k) is Sum_i (-1)^(i-1) y_i.
LINKS
EXAMPLE
The terms together with their binary indices begin:
0: ()
9: (3,1)
11: (2,1,1)
14: (1,1,2)
130: (6,2)
133: (5,2,1)
135: (5,1,1,1)
138: (4,2,2)
141: (4,1,2,1)
143: (4,1,1,1,1)
148: (3,2,3)
153: (3,1,3,1)
155: (3,1,2,1,1)
158: (3,1,1,1,2)
MATHEMATICA
ats[y_]:=Sum[(-1)^(i-1)*y[[i]], {i, Length[y]}];
stc[n_]:=Differences[Prepend[Join@@Position[Reverse[IntegerDigits[n, 2]], 1], 0]]//Reverse;
Select[Range[0, 1000], Total[stc[#]]==2*ats[stc[#]]&]
CROSSREFS
These compositions are counted by A262977.
A011782 counts compositions.
A034871 counts compositions of 2n with alternating sum 2k.
A097805 counts compositions by alternating (or reverse-alternating) sum.
A345197 counts compositions by length and alternating sum.
KEYWORD
nonn
AUTHOR
Gus Wiseman, Oct 29 2021
STATUS
approved