login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A088705
First differences of A000120. One minus exponent of 2 in n.
11
0, 1, 0, 1, -1, 1, 0, 1, -2, 1, 0, 1, -1, 1, 0, 1, -3, 1, 0, 1, -1, 1, 0, 1, -2, 1, 0, 1, -1, 1, 0, 1, -4, 1, 0, 1, -1, 1, 0, 1, -2, 1, 0, 1, -1, 1, 0, 1, -3, 1, 0, 1, -1, 1, 0, 1, -2, 1, 0, 1, -1, 1, 0, 1, -5, 1, 0, 1, -1, 1, 0, 1, -2, 1, 0, 1, -1, 1, 0, 1, -3, 1, 0, 1
OFFSET
0,9
COMMENTS
The number of 1's in the binary expansion of n+1 minus the number of 1's in the binary expansion of n.
FORMULA
For n > 0: a(n) = A000120(n) - A000120(n-1) = 1 - A007814(n).
Multiplicative with a(2^e) = 1-e, a(p^e) = 1 otherwise. - David W. Wilson, Jun 12 2005
G.f.: Sum{k>=0} t/(1+t), t=x^2^k.
a(0) = 0, a(2*n) = a(n) - 1, a(2*n+1) = 1.
Let T(x) be the g.f., then T(x)-T(x^2)=x/(1+x). - Joerg Arndt, May 11 2010
Dirichlet g.f.: zeta(s) * (2-2^s)/(1-2^s). - Amiram Eldar, Sep 18 2023
MAPLE
add(x^(2^k)/(1+x^(2^k)), k=0..20); series(%, x, 1001); seriestolist(%); # To get up to a million terms, from N. J. A. Sloane, Aug 31 2014
MATHEMATICA
a[n_] := If[n<1, 0, If[Mod[n, 2] == 0, a[n/2] - 1, 1]]; Array[a, 60, 0] (* Amiram Eldar, Nov 26 2018 *)
PROG
(PARI) a(n)=if(n<1, 0, if(n%2==0, a(n/2)-1, 1))
(PARI) a(n)=if(n<1, 0, 1-valuation(n, 2))
(Haskell)
a088705 n = a088705_list !! n
a088705_list = 0 : zipWith (-) (tail a000120_list) a000120_list
-- Reinhard Zumkeller, Dec 11 2011
(Python)
def A088705(n): return 1-(~n & n-1).bit_length() # Chai Wah Wu, Sep 18 2024
CROSSREFS
KEYWORD
sign,easy,mult
AUTHOR
Ralf Stephan, Oct 10 2003
STATUS
approved