login
A357625
Numbers k such that the k-th composition in standard order has half-alternating sum 0.
20
0, 14, 15, 44, 45, 46, 52, 53, 54, 59, 61, 152, 153, 154, 156, 168, 169, 170, 172, 179, 181, 185, 200, 201, 202, 204, 211, 213, 217, 230, 231, 234, 235, 239, 242, 243, 247, 254, 255, 560, 561, 562, 564, 568, 592, 593, 594, 596, 600, 611, 613, 617, 625, 656
OFFSET
1,2
COMMENTS
We define the half-alternating sum of a sequence (A, B, C, D, E, F, G, ...) to be A + B - C - D + E + F - G - ...
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 sequence together with the corresponding compositions begins:
0: ()
14: (1,1,2)
15: (1,1,1,1)
44: (2,1,3)
45: (2,1,2,1)
46: (2,1,1,2)
52: (1,2,3)
53: (1,2,2,1)
54: (1,2,1,2)
59: (1,1,2,1,1)
61: (1,1,1,2,1)
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]}];
Select[Range[0, 100], halfats[stc[#]]==0&]
PROG
(Python)
from itertools import count, islice
def comp(n): #row n of A066099 after Franklin T. Adams-Watters
v, k = [], 0
while n > 0:
k += 1
if n%2 == 1:
v.append(k)
k = 0
n = n//2
return(v[::-1])
def a_gen():
for n in count(0):
c = comp(n)
x = sum(c[i]*(-1)**(i//2) for i in range(len(c)))
if x == 0:
yield(n)
A357625_list = list(islice(a_gen(), 60)) # John Tyler Rascoe, Jun 01 2024
CROSSREFS
See link for sequences related to standard compositions.
The version for full alternating sum is A344619.
Positions of zeros in A357621.
The reverse version is A357626.
The skew-alternating form is A357627, reverse A357628.
The version for prime indices is A357631.
The version for Heinz numbers of partitions is A357635.
A124754 gives alternating sum of standard compositions, reverse A344618.
A357637 counts partitions by half-alternating sum, skew A357638.
A357641 counts comps w/ half-alt sum 0, partitions A357639, even A357642.
Sequence in context: A213386 A370403 A370405 * A041404 A041402 A041929
KEYWORD
nonn
AUTHOR
Gus Wiseman, Oct 08 2022
STATUS
approved