%I #65 Jan 09 2025 19:08:26
%S 1,0,2,1,2,0,2,2,3,0,2,2,2,0,4,3,2,0,2,2,4,0,2,4,3,0,4,2,2,0,2,4,4,0,
%T 4,3,2,0,4,4,2,0,2,2,6,0,2,6,3,0,4,2,2,0,4,4,4,0,2,4,2,0,6,5,4,0,2,2,
%U 4,0,2,6,2,0,6,2,4,0,2,6,5,0,2,4,4,0,4,4,2,0,4,2,4,0,4,8,2,0,6,3,2,0,2,4,8
%N Number of divisors of n if n odd, number of divisors of n/4 if n divisible by 4, otherwise 0.
%C First occurrence of k: 2, 1, 3, 9, 15, 64, 45, 256, 96, 144, 192, 4096, 240, ????, 768, 576, 480, ????, 720, ..., . See A246063. - _Robert G. Wilson v_, Oct 31 2013
%C a(n) is the number of pairs (u, v) in NxZ satisfying u^2-v^2=n. See Kühleitner. - _Michel Marcus_, Jul 30 2017
%C The g.f. in the form Sum_{k >= 1} x^(k^2) * (1 + x^(2*k))/(1 - x^(2*k)) = Sum_{k >= 1} x^(k^2) * (1 + x^(2*k))/(1 + x^(2*k) - 2*x^(2*k)) == Sum_{k >= 1} x^(k^2) (mod 2). It follows that a(n) is odd iff n = k^2 for some positive integer k. - _Peter Bala_, Jan 08 2025
%D G. H. Hardy, Ramanujan: twelve lectures on subjects suggested by his life and work, AMS Chelsea Publishing, Providence, Rhode Island, 2002, p. 142.
%H Ray Chandler, <a href="/A112329/b112329.txt">Table of n, a(n) for n = 1..10000</a>
%H M. Kühleitner, <a href="https://www.emis.de/journals/AMUC/_vol-61/_no_1/_kuhleit/kuhleitn.html">An Omega Theorem on Differences of Two Squares</a>, Acta Mathematica Universitatis Comenianae, Vol. 61, 1 (1992) pp. 117-123. See Lemma 1 p. 2.
%H John Shareshian and Sheila Sundaram, <a href="https://arxiv.org/abs/2305.12007">Ramanujan sums and rectangular power sums</a>, arXiv:2305.12007 [math.CO], 2023. Mentions this sequence.
%H N. J. A. Sloane et al., <a href="https://oeis.org/wiki/Binary_Quadratic_Forms_and_OEIS">Binary Quadratic Forms and OEIS</a> (Index to related sequences, programs, references)
%F Multiplicative with a(2^e) = e-1 if e>0, a(p^e) = 1+e if p>2.
%F G.f.: Sum_{k>0} x^k / (1 - (-x)^k) = Sum_{k>0} -(-x)^k / (1 + (-x)^k).
%F Möbius transform is period 4 sequence [ 1, -1, 1, 1, ...].
%F G.f.: Sum_{k>=1} x^(k^2) * (1+x^(2*k))/(1-x^(2*k)). - _Joerg Arndt_, Nov 08 2010
%F a(4*n + 2) = 0. a(n) = -(-1)^n * A048272(n). a(2*n - 1) = A099774(n). a(4*n) = A000005(n). a(4*n + 1) = A000005(4*n + 1). a(4*n - 1) = 2 * A078703(n).
%F a(n) = A094572(n) / 2. - _Ray Chandler_, Aug 23 2014
%F Bisection: a(2*k-1) = A000005(2*k-1), a(2*k) = A183063(2*k) - A001227(2*k), k >= 1. See the Hardy reference, p. 142 where a(n) = sigma^*_0(n). - _Wolfdieter Lang_, Jan 07 2017
%F a(n) = d(n) - 2*d(n/2) + 2*d(n/4) where d(n) = 0 if n is not an integer. See Kühleitner.
%F a(n) = Sum_{d|n} [(d mod 2) = (n/d mod 2)], where [ ] is the Iverson bracket. - _Wesley Ivan Hurt_, Mar 21 2022
%F From _Amiram Eldar_, Nov 29 2022: (Start)
%F Dirichlet g.f.: zeta(s)^2*(1 + 2^(1-2*s) - 2^(1-s)).
%F Sum_{k=1..n} a(k) ~ n*log(n)/2 + (2*gamma-1)*n/2, where gamma is Euler's constant (A001620). (End)
%F a(n) = (-1)^n * Sum_{d|2*n} cos(d*Pi/2). - _Ridouane Oudra_, Sep 27 2024
%e x + 2*x^3 + x^4 + 2*x^5 + 2*x^7 + 2*x^8 + 3*x^9 + 2*x^11 + 2*x^12 + ...
%p f:= proc(n) if n::odd then numtheory:-tau(n) elif n mod 4 = 0 then numtheory:-tau(n/4) else 0 fi end proc;
%p seq(f(i),i=1..100); # _Robert Israel_, Aug 24 2014
%t Rest[ CoefficientList[ Series[ Sum[x^k/(1 - (-x)^k), {k, 111}], {x, 0, 110}], x]] (* _Robert G. Wilson v_, Sep 20 2005 *)
%t Table[If[OddQ[n],DivisorSigma[0,n],If[OddQ[n/2],0,DivisorSigma[0,n/4]]],{n,100} ] (* _Ray Chandler_, Aug 23 2014 *)
%o (PARI) {a(n) = if( n<1, 0, (-1)^n * sumdiv( n, d, (-1)^d))}
%o (PARI) {a(n) = if( n<1, 0, if( n%2, numdiv(n), if( n%4, 0, numdiv(n/4))))} /* _Michael Somos_, Sep 02 2006 */
%o (PARI) d(n) = if (denominator(n)==1, numdiv(n), 0);
%o a(n) = numdiv(n) - 2*d(n/2) + 2*d(n/4); \\ _Michel Marcus_, Jul 30 2017
%Y Cf. A000005, A001227, A001620, A048272, A078703, A094572, A099774, A183063, A246063.
%K nonn,mult
%O 1,3
%A _Michael Somos_, Sep 04 2005