login
a(n) = Sum_{ d divides n, n/d=1 mod 4} d - Sum_{ d divides n, n/d=3 mod 4} d.
24

%I #40 Sep 26 2024 16:20:25

%S 1,2,2,4,6,4,6,8,7,12,10,8,14,12,12,16,18,14,18,24,12,20,22,16,31,28,

%T 20,24,30,24,30,32,20,36,36,28,38,36,28,48,42,24,42,40,42,44,46,32,43,

%U 62,36,56,54,40,60,48,36,60,58,48,62,60,42,64,84,40

%N a(n) = Sum_{ d divides n, n/d=1 mod 4} d - Sum_{ d divides n, n/d=3 mod 4} d.

%C Multiplicative with a(p^e)=p^e if p=2, (p^(e+1)-1)/(p-1) if p==1 (mod 4), else (p^(e+1)+(-1)^e)/(p+1). - _Michael Somos_, May 02 2005

%C Multiplicative because it is the Dirichlet convolution of A000027 = n and A101455 = [1 0 -1 0 1 0 -1 ...], which are both multiplicative. - _Christian G. Bower_, May 17 2005

%H Seiichi Manyama, <a href="/A050469/b050469.txt">Table of n, a(n) for n = 1..10000</a>

%H J. W. L. Glaisher, <a href="https://books.google.com/books?id=bLs9AQAAMAAJ&amp;pg=RA1-PA1">On the representations of a number as the sum of two, four, six, eight, ten, and twelve squares</a>, Quart. J. Math. 38 (1907), 1-62 (see p. 4 and p. 8).

%H <a href="/index/Ge#Glaisher">Index entries for sequences mentioned by Glaisher</a>.

%F G.f.: Sum_{n>=1} n*x^n/(1+x^(2*n)). - _Vladeta Jovovic_, Oct 16 2002

%F L.g.f.: Sum_{k>=1} arctan(x^k). - _Ilya Gutkovskiy_, Dec 16 2019

%F O.g.f.: Sum_{n >= 1} (-1)^(n+1) * x^(2*n-1)/(1 - x^(2*n-1))^2. - _Peter Bala_, Jan 04 2021

%F Sum_{k=1..n} a(k) ~ c * n^2, where c = (1/2) * Product_{primes p == 1 (mod 4)} 1/(1-1/p^2) * Product_{primes p == 3 (mod 4)} 1/(1+1/p^2) = (1/2) * A175647 / A243381 = A006752/2 = 0.4579827970... . - _Amiram Eldar_, Nov 06 2022, Nov 05 2023

%F a(n) = Sum_{d|n} (n/d)*sin(d*Pi/2). - _Ridouane Oudra_, Sep 26 2024

%t max = 70; s = Sum[n*x^(n-1)/(1+x^(2*n)), {n, 1, max}] + O[x]^max; CoefficientList[s, x] (* _Jean-François Alcover_, Dec 02 2015 *)

%t f[p_, e_] := Which[p == 2, p^e, Mod[p, 4] == 1, (p^(e + 1) - 1)/(p - 1), Mod[p, 4] == 3, (p^(e + 1) + (-1)^e)/(p + 1)]; a[1] = 1; a[n_] := Times @@ (f @@@ FactorInteger[n]); Array[a, 100] (* _Amiram Eldar_, Nov 06 2022 *)

%o (PARI) a(n)=if(n<1,0,sumdiv(n,d,d*((n/d%4==1)-(n/d%4==3))))

%o (PARI) {a(n)=local(A,p,e); if(n<2, n==1, A=factor(n); prod(k=1,matsize(A)[1], if(p=A[k,1], e=A[k,2]; if(p==2, p^e, if(p%4==1, (p^(e+1)-1)/(p-1), (p^(e+1)+(-1)^e)/(p+1)))))) } /* _Michael Somos_, May 02 2005 */

%o (PARI) a(n)=if(n<1,0,polcoeff(sum(k=1,n,k*x^k/(1+x^(2*k)),x*O(x^n)),n))

%Y Cf. A006752, A050470, A050471, A050468, A175647, A243381.

%K nonn,mult

%O 1,2

%A _N. J. A. Sloane_, Dec 23 1999