OFFSET
1,2
COMMENTS
Row 0 is empty, so offset is 1.
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 k-based partial alternating sums of a finite sequence q are given by pas(q,k)_j = (-1)^j * k + Sum_{i=1..j} (-1)^(i+j) * q_i. This is a signed version of the partial sums transformation, inverse to the "first sums" transformation.
For example, the k-based partial alternating sums of q = (a,b,c,d,e) are:
pas(q,k)_0 = k
pas(q,k)_1 = -k + a
pas(q,k)_2 = k - a + b
pas(q,k)_3 = -k + a - b + c
pas(q,k)_4 = k - a + b - c + d
pas(q,k)_5 = -k + a - b + c - d + e
These are trimmed by removing the zeroth line (which is always k).
EXAMPLE
The 19-th standard composition is (3,1,1), and pas((3,1,1),0) = (0,3,-2,3), so row 19 is (3,-2,3).
Triangle begins:
0: .
1: 1
2: 2
3: 1 0
4: 3
5: 2 -1
6: 1 1
7: 1 0 1
8: 4
9: 3 -2
10: 2 0
11: 2 -1 2
12: 1 2
13: 1 1 0
14: 1 0 2
15: 1 0 1 0
16: 5
17: 4 -3
18: 3 -1
19: 3 -2 3
20: 2 1
MATHEMATICA
stc[n_]:=Differences[Prepend[Join @@ Position[Reverse[IntegerDigits[n, 2]], 1], 0]]//Reverse;
pas[y_, k_]:=Table[(-1)^j*k+Sum[(-1)^(i+j)*y[[i]], {i, j}], {j, 0, Length[y]}];
Table[Rest[pas[stc[n], 0]], {n, 20}]
CROSSREFS
Row lengths are A000120.
First term in each row is A065120.
The reverse version is A391984.
A011782 counts compositions.
A116406 counts compositions with alternating sum >= 0.
A357213 counts compositions by sum of first sums.
KEYWORD
sign,tabf
AUTHOR
Gus Wiseman, Jan 10 2026
STATUS
approved
