|
|
A037861
|
|
(Number of 0's) - (number of 1's) in the base-2 representation of n.
|
|
41
|
|
|
1, -1, 0, -2, 1, -1, -1, -3, 2, 0, 0, -2, 0, -2, -2, -4, 3, 1, 1, -1, 1, -1, -1, -3, 1, -1, -1, -3, -1, -3, -3, -5, 4, 2, 2, 0, 2, 0, 0, -2, 2, 0, 0, -2, 0, -2, -2, -4, 2, 0, 0, -2, 0, -2, -2, -4, 0, -2, -2, -4, -2, -4, -4, -6, 5, 3, 3, 1, 3, 1, 1, -1, 3
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
0,4
|
|
COMMENTS
|
-Sum_{n>=1} a(n)/((2*n)*(2*n+1)) = the "alternating Euler constant" log(4/Pi) = 0.24156... - (see A094640 and Sondow 2005, 2010).
|
|
LINKS
|
|
|
FORMULA
|
a(2*n) = a(n) + 1; a(2*n + 1) = a(2*n) - 2 = a(n) - 1. (End)
a(n) = b(n) for n > 0 with b(0) = 0 and b(n) = b(floor(n/2)) + (-1)^(n mod 2). - Reinhard Zumkeller, Dec 31 2007
G.f.: 1 + (1/(1 - x))*Sum_{k>=0} x^(2^k)*(x^(2^k) - 1)/(1 + x^(2^k)). - Ilya Gutkovskiy, Apr 07 2018
|
|
MAPLE
|
L:= convert(n, base, 2);
numboccur(0, L) - numboccur(1, L)
end proc:
|
|
MATHEMATICA
|
Table[Count[ IntegerDigits[n, 2], 0] - Count[IntegerDigits[n, 2], 1], {n, 0, 75}]
|
|
PROG
|
(Haskell)
(Python)
return 2*format(n, 'b').count('0')-len(format(n, 'b')) # Chai Wah Wu, Mar 07 2016
(PARI) a(n) = if (n==0, 1, 1 + logint(n, 2) - 2*hammingweight(n)); \\ Michel Marcus, May 15 2020 and Jun 16 2020
|
|
CROSSREFS
|
See A268289 for a recurrence based on this sequence.
|
|
KEYWORD
|
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|