OFFSET
1,1
COMMENTS
The alternating sum of a sequence (y_1,...,y_k) is Sum_i (-1)^(i-1) y_i.
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 initial terms and corresponding compositions:
2: (2) 137: (4,3,1)
9: (3,1) 139: (4,2,1,1)
11: (2,1,1) 142: (4,1,1,2)
14: (1,1,2) 146: (3,3,2)
34: (4,2) 149: (3,2,2,1)
37: (3,2,1) 151: (3,2,1,1,1)
39: (3,1,1,1) 154: (3,1,2,2)
42: (2,2,2) 157: (3,1,1,2,1)
45: (2,1,2,1) 159: (3,1,1,1,1,1)
47: (2,1,1,1,1) 164: (2,3,3)
52: (1,2,3) 169: (2,2,3,1)
57: (1,1,3,1) 171: (2,2,2,1,1)
59: (1,1,2,1,1) 174: (2,2,1,1,2)
62: (1,1,1,1,2) 178: (2,1,3,2)
132: (5,3) 181: (2,1,2,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], ats[stc[#]]==2&]
CROSSREFS
These compositions are counted by A088218.
These are the positions of 2's in A124754.
The case of partitions of 2n is A344741.
The version for reverse-alternating sum is A345922.
The opposite (negative 2) version is A345924.
A011782 counts compositions.
A097805 counts compositions by alternating (or reverse-alternating) sum.
A120452 counts partitions of 2n with reverse-alternating sum 2.
A345197 counts compositions by sum, length, and alternating sum.
Compositions of n, 2n, or 2n+1 with alternating/reverse-alternating sum k:
KEYWORD
nonn
AUTHOR
Gus Wiseman, Jul 11 2021
STATUS
approved