A048272 Number of odd divisors of n minus number of even divisors of n.
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, 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, 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
Offset: 1
Examples
a(20) = -2 because 20 = 2^2*5^1 and (1-2)*(1+1) = -2. G.f. = x + 2*x^3 - x^4 + 2*x^5 + 2*x^7 - 2*x^8 + 3*x^9 + 2*x^11 - 2*x^12 + ...
References
- Louis Comtet, Advanced Combinatorics, Reidel, 1974, p. 162, #16, (6), first formula.
- S. Ramanujan, Notebooks, Tata Institute of Fundamental Research, Bombay 1957 Vol. 1, see page 97, 7(ii).
Links
- T. D. Noe, Table of n, a(n) for n = 1..10000
- J. W. L. Glaisher, On the representations of a number as the sum of two, four, six, eight, ten, and twelve squares, Quart. J. Math. 38 (1907), 1-62 (see p. 4 and p. 8).
- Vaclav Kotesovec, Plot of Sum_{k=1..n} a(k) / n, for n = 1..1000000
- P. A. MacMahon, Divisors of numbers and their continuations in the theory of partitions, Proc. London Math. Soc., 19 (1921), 75-113; Coll. Papers II, pp. 303-341.
- Mircea Merca, Combinatorial interpretations of a recent convolution for the number of divisors of a positive integer, Journal of Number Theory, Volume 160, March 2016, Pages 60-75, function tau_{o-e}(n).
- Index entries for sequences mentioned by Glaisher.
Crossrefs
Programs
-
Haskell
a048272 n = a001227 n - a183063 n -- Reinhard Zumkeller, Jan 21 2012
-
Magma
[&+[(-1)^(d+1):d in Divisors(n)] :n in [1..95] ]; // Marius A. Burtea, Aug 10 2019
-
Maple
add(x^n/(1+x^n), n=1..60): series(%,x,59); A048272 := proc(n) local a; a := 1 ; for pfac in ifactors(n)[2] do if pfac[1] = 2 then a := a*(1-pfac[2]) ; else a := a*(pfac[2]+1) ; end if; end do: a ; end proc: # Schmitt, sign corrected R. J. Mathar, Jun 18 2016 # alternative Maple program: a:= n-> -add((-1)^d, d=numtheory[divisors](n)): seq(a(n), n=1..100); # Alois P. Heinz, Feb 28 2018
-
Mathematica
Rest[ CoefficientList[ Series[ Sum[x^k/(1 - (-x)^k), {k, 111}], {x, 0, 110}], x]] (* Robert G. Wilson v, Sep 20 2005 *) dif[n_]:=Module[{divs=Divisors[n]},Count[divs,?OddQ]-Count[ divs, ?EvenQ]]; Array[dif,100] (* Harvey P. Dale, Aug 21 2011 *) a[n]:=Sum[-(-1)^d,{d,Divisors[n]}] (* Steven Foster Clark, May 04 2018 *) f[p_, e_] := If[p == 2, 1 - e, 1 + e]; a[n_] := Times @@ f @@@ FactorInteger[n]; a[1] = 1; Array[a, 100] (* Amiram Eldar, Jun 09 2022 *)
-
PARI
{a(n) = if( n<1, 0, -sumdiv(n, d, (-1)^d))}; /* Michael Somos, Jul 22 2006 */
-
PARI
N=17; default(seriesprecision,N); x=z+O(z^(N+1)) c=sum(j=1,N,j*x^j); \\ log case s=-log(prod(j=1,N,(1+x^j)^(1/j))); s=serconvol(s,c) v=Vec(s) \\ Joerg Arndt, May 03 2008
-
PARI
a(n)=my(o=valuation(n,2),f=factor(n>>o)[,2]);(1-o)*prod(i=1,#f,f[i]+1) \\ Charles R Greathouse IV, Feb 10 2013
-
PARI
a(n)=direuler(p=1,n,if(p==2,(1-2*X)/(1-X)^2,1/(1-X)^2))[n] /* Ralf Stephan, Mar 27 2015 */
-
PARI
{a(n) = my(d = n -> if(frac(n), 0, numdiv(n))); if( n<1, 0, if( n%4, 1, -1) * (d(n) - 2*d(n/2) + 2*d(n/4)))}; /* Michael Somos, Aug 11 2017 */
Formula
Coefficients in expansion of Sum_{n >= 1} x^n/(1+x^n) = Sum_{n >= 1} (-1)^(n-1)*x^n/(1-x^n). Expand Sum 1/(1+x^n) in powers of 1/x.
If n = 2^p1*3^p2*5^p3*7^p4*11^p5*..., a(n) = (1-p1)*Product_{i>=2} (1+p_i).
Multiplicative with a(2^e) = 1 - e and a(p^e) = 1 + e if p > 2. - Vladeta Jovovic, Jan 27 2002
a(n) = (-1)*Sum_{d|n} (-1)^d. - Benoit Cloitre, May 12 2003
Moebius transform is period 2 sequence [1, -1, ...]. - Michael Somos, Jul 22 2006
G.f.: Sum_{k>0} -(-1)^k * x^(k^2) * (1 + x^(2*k)) / (1 - x^(2*k)) [Ramanujan]. - Michael Somos, Jul 22 2006
Equals A051731 * [1, -1, 1, -1, 1, ...]. - Gary W. Adamson, Nov 07 2007
From Reinhard Zumkeller, Jan 21 2012: (Start)
a(A008586(n)) < 0; a(A005843(n)) <= 0; a(A016825(n)) = 0; a(A042968(n)) >= 0; a(A005408(n)) > 0. (End)
From Peter Bala, Jan 07 2015: (Start)
Logarithmic g.f.: log( Product_{n >= 1} (1 + x^n)^(1/n) ) = Sum_{n >= 1} a(n)*x^n/n.
a(n) = A001227(n) - A183063(n). By considering the logarithmic generating functions of these three sequences we obtain the identity
( Product_{n >= 0} (1 - x^(2*n+1))^(1/(2*n+1)) )^2 = Product_{n >= 1} ( (1 - x^n)/(1 + x^n) )^(1/n). (End)
Dirichlet g.f.: zeta(s)*eta(s) = zeta(s)^2*(1-2^(-s+1)). - Ralf Stephan, Mar 27 2015
a(2*n - 1) = A099774(n). - Michael Somos, Aug 12 2017
From Paul D. Hanna, Aug 10 2019: (Start)
G.f.: Sum_{n>=0} x^n * Sum_{k=0..n} binomial(n,k) * (x^(n+1) - x^k)^(n-k) = Sum_{n>=0} a(n)*x^(2*n).
G.f.: Sum_{n>=0} x^n * Sum_{k=0..n} binomial(n,k) * (x^(n+1) + x^k)^(n-k) * (-1)^k = Sum_{n>=0} a(n)*x^(2*n). (End)
Limit_{m->oo} (1/m) * Sum_{k=1..m} a(k)/A000005(k) = 2*log(2)-1. - Amiram Eldar, Mar 01 2023
Extensions
New definition from Vladeta Jovovic, Jan 27 2002
Comments