A050457 a(n) = Sum_{ d divides n, d==1 mod 4} d - Sum_{ d divides n, d==3 mod 4} d.
1, 1, -2, 1, 6, -2, -6, 1, 7, 6, -10, -2, 14, -6, -12, 1, 18, 7, -18, 6, 12, -10, -22, -2, 31, 14, -20, -6, 30, -12, -30, 1, 20, 18, -36, 7, 38, -18, -28, 6, 42, 12, -42, -10, 42, -22, -46, -2, 43, 31, -36, 14, 54, -20, -60, -6, 36, 30, -58, -12, 62, -30, -42, 1, 84, 20, -66, 18, 44, -36, -70
Offset: 1
Links
- Indranil Ghosh, Table of n, a(n) for n = 1..5000
- 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).
- Index entries for sequences mentioned by Glaisher.
Crossrefs
Column k=1 of A322143.
Programs
-
Maple
with(numtheory): A050457 := proc(n) local count1, count3, d; count1 := 0: count3 := 0: for d in numtheory[divisors](n) do if d mod 4 = 1 then count1 := count1+d elif d mod 4 = 3 then count3 := count3+d fi: end do: count1-count3; end proc: # Ridouane Oudra, Feb 02 2020 # second Maple program: a:= n-> add(`if`(d::odd, d*(-1)^((d-1)/2), 0), d=numtheory[divisors](n)): seq(a(n), n=1..100); # Alois P. Heinz, Feb 03 2020
-
Mathematica
Table[Sum[KroneckerSymbol[-4, d] d , {d, Divisors[n]}], {n, 71}] (* Indranil Ghosh, Mar 16 2017 *) f[p_, e_] := If[Mod[p, 4] == 1, (p^(e+1)-1)/(p-1), ((-p)^(e+1)-1)/(-p-1)]; f[2, e_] := 1; a[1] = 1; a[n_] := Times @@ f @@@ FactorInteger[n]; Array[a, 100] (* Amiram Eldar, Sep 27 2023 *)
-
PARI
{a(n)=local(A,p,e); if(n<1, 0, A=factor(n); prod(k=1,matsize(A)[1], if(p=A[k,1], e=A[k,2]; if(p==2, 1, p*=kronecker(-4,p); (p^(e+1)-1)/(p-1)))))} /* Michael Somos, May 29 2005 */
-
PARI
{a(n)=if(n<1, 0, sumdiv(n, d, kronecker(-4, d)*d))} /* Michael Somos, May 29 2005 */
Formula
a(n) is multiplicative with a(p^e)=1 if p=2, a(p^e)=(p^(e+1)-1)/(p-1) if p == 1 (mod 4), a(p^e)=((-p)^(e+1)-1)/(-p-1) if p == 3 (mod 4). - Michael Somos, May 29 2005
G.f.: Sum_{k>=1} (-1)^(k-1)*(2*k - 1)*x^(2*k-1)/(1 - x^(2*k-1)). - Ilya Gutkovskiy, Dec 22 2018
a(n) = Im(Sum_{d|n} d*i^d). - Ridouane Oudra, Feb 02 2020
a(n) = Sum_{d|n} d*sin(d*Pi/2). - Ridouane Oudra, Feb 18 2023
Comments