OFFSET
1,3
COMMENTS
Multiplicative because it is the Inverse Moebius transform of [1 0 -3 0 5 0 -7 ...], which is multiplicative. - Christian G. Bower, May 18 2005
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).
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
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 *)
PROG
(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 */
CROSSREFS
KEYWORD
sign,easy,mult
AUTHOR
N. J. A. Sloane, Dec 23 1999
STATUS
approved