login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A345927 Alternating sum of the binary expansion of n (row n of A030190). Replace 2^k with (-1)^(A070939(n)-k) in the binary expansion of n (compare to the definition of A065359). 4
0, 1, 1, 0, 1, 2, 0, 1, 1, 0, 2, 1, 0, -1, 1, 0, 1, 2, 0, 1, 2, 3, 1, 2, 0, 1, -1, 0, 1, 2, 0, 1, 1, 0, 2, 1, 0, -1, 1, 0, 2, 1, 3, 2, 1, 0, 2, 1, 0, -1, 1, 0, -1, -2, 0, -1, 1, 0, 2, 1, 0, -1, 1, 0, 1, 2, 0, 1, 2, 3, 1, 2, 0, 1, -1, 0, 1, 2, 0, 1, 2, 3, 1, 2 (list; graph; refs; listen; history; text; internal format)
OFFSET
0,6
COMMENTS
The alternating sum of a sequence (y_1,...,y_k) is Sum_i (-1)^(i-1) y_i.
LINKS
FORMULA
a(n) = (-1)^(A070939(n)-1)*A065359(n).
EXAMPLE
The binary expansion of 53 is (1,1,0,1,0,1), so a(53) = 1 - 1 + 0 - 1 + 0 - 1 = -2.
MATHEMATICA
ats[y_]:=Sum[(-1)^(i-1)*y[[i]], {i, Length[y]}];
Table[ats[IntegerDigits[n, 2]], {n, 0, 100}]
PROG
(PARI) a(n) = subst(Pol(Vecrev(binary(n))), x, -1); \\ Michel Marcus, Jul 19 2021
(Python)
def a(n): return sum((-1)**k for k, bi in enumerate(bin(n)[2:]) if bi=='1')
print([a(n) for n in range(84)]) # Michael S. Branicky, Jul 19 2021
CROSSREFS
Binary expansions of each nonnegative integer are the rows of A030190.
The positions of 0's are A039004.
The version for prime factors is A071321 (reverse: A071322).
Positions of first appearances are A086893.
The version for standard compositions is A124754 (reverse: A344618).
The version for prime multiplicities is A316523.
The version for prime indices is A316524 (reverse: A344616).
A003714 lists numbers with no successive binary indices.
A070939 gives the length of an integer's binary expansion.
A103919 counts partitions by sum and alternating sum.
A328594 lists numbers whose binary expansion is aperiodic.
A328595 lists numbers whose reversed binary expansion is a necklace.
Sequence in context: A319571 A086966 A140080 * A065359 A087372 A036431
KEYWORD
sign
AUTHOR
Gus Wiseman, Jul 14 2021
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 19 09:23 EDT 2024. Contains 371782 sequences. (Running on oeis4.)