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
Reinhard Zumkeller, Table of n, a(n) for n = 0..10000
Jonathan Sondow, Double integrals for Euler's constant and ln(4/Pi) and an analog of Hadjicostas's formula, arXiv:math/0211148 [math.CA], 2002-2004; Amer. Math. Monthly 112 (2005), 61-65.
Jonathan Sondow, New Vacca-Type Rational Series for Euler's Constant and Its "Alternating" Analog ln(4/Pi), arXiv:math/0508042 [math.NT], 2005; Additive Number Theory, Festschrift In Honor of the Sixtieth Birthday of Melvyn B. Nathanson (D. Chudnovsky and G. Chudnovsky, eds.), Springer, 2010, pp. 331-340.
Ralf Stephan, Divide-and-conquer generating functions. I. Elementary sequences, arXiv:math/0307027 [math.CO], 2003.
Ralf Stephan, Some divide-and-conquer sequences with (relatively) simple ordinary generating functions, 2004.
Ralf Stephan, Table of generating functions (ps file).
Ralf Stephan, Table of generating functions (pdf file).
FORMULA
From Henry Bottomley, Oct 27 2000: (Start)
a(2*n) = a(n) + 1; a(2*n + 1) = a(2*n) - 2 = a(n) - 1. (End)
G.f. satisfies A(x) = (1 + x)*A(x^2) - x*(2 + x)/(1 + x). - Franklin T. Adams-Watters, Dec 26 2006
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
A037861:= proc(n) local L;
L:= convert(n, base, 2);
numboccur(0, L) - numboccur(1, L)
end proc:
map(A037861, [$0..100]); # Robert Israel, Mar 08 2016
MATHEMATICA
Table[Count[ IntegerDigits[n, 2], 0] - Count[IntegerDigits[n, 2], 1], {n, 0, 75}]
PROG
(Haskell)
a037861 n = a023416 n - a000120 n -- Reinhard Zumkeller, Aug 01 2013
(Python)
def A037861(n):
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
KEYWORD
AUTHOR
STATUS
approved