A357622 Half-alternating sum of the reversed n-th composition in standard order.
0, 1, 2, 2, 3, 3, 3, 1, 4, 4, 4, 0, 4, 2, 2, 0, 5, 5, 5, -1, 5, 1, 1, -1, 5, 3, 3, -1, 3, 1, 1, 1, 6, 6, 6, -2, 6, 0, 0, -2, 6, 2, 2, -2, 2, 0, 0, 2, 6, 4, 4, -2, 4, 0, 0, 0, 4, 2, 2, 0, 2, 2, 2, 2, 7, 7, 7, -3, 7, -1, -1, -3, 7, 1, 1, -3, 1, -1, -1, 3, 7, 3
Offset: 0
Keywords
Examples
The 357-th composition is (2,1,3,2,1) so a(357) = 1 + 2 - 3 - 1 + 2 = 1.
Links
Crossrefs
Programs
-
Mathematica
stc[n_]:=Differences[Prepend[Join @@ Position[Reverse[IntegerDigits[n,2]],1],0]]//Reverse; halfats[f_]:=Sum[f[[i]]*(-1)^(1+Ceiling[i/2]),{i,Length[f]}]; Table[halfats[Reverse[stc[n]]],{n,0,100}]
Comments