OFFSET
1,2
LINKS
David A. Corneth, Table of n, a(n) for n = 1..10000
László Tóth, Counting solutions of quadratic congruences in several variables revisited, arXiv preprint arXiv:1404.4214 [math.NT], 2014.
László Tóth, Counting Solutions of Quadratic Congruences in Several Variables Revisited, J. Int. Seq. 17 (2014), Article 14.11.6.
FORMULA
Multiplicative, with a(2^e) = 2^(2e+1) for e>=1, a(p^e) = p^(2e-1)*(p^(e+1)+p^e-1) for p > 2, e>=1.
Sum_{k=1..n} a(k) ~ c * n^4 + O(n^3 * log(n)), where c = 5*Pi^2/(168*zeta(3)) = 0.244362... (Tóth, 2014). - Amiram Eldar, Oct 18 2022
EXAMPLE
For n=2 the a(2)=8 solutions are (0,0,0,0), (1,1,0,0), (1,0,1,0), (1,0,0,1), (0,1,1,0), (0,1,0,1), (0,0,1,1), (1,1,1,1).
MAPLE
A240547 := proc(n) local a, x, y, z, t ; a := 0 ; for x from 0 to n-1 do for y
from 0 to n-1 do for z from 0 to n-1 do for t from 0 to n-1 do if
(x^2+y^2+z^2+t^2) mod n = 0 mod n then a := a+1 ; fi; od; od ; od; od;
a ; end proc;
# alternative
A240547 := proc(n)
a := 1;
for pe in ifactors(n)[2] do
p := op(1, pe) ;
e := op(2, pe) ;
if p = 2 then
a := a*p^(2*e+1) ;
else
a := a* p^(2*e-1)*(p^(e+1)+p^e-1) ;
end if;
end do:
a ;
end proc:
seq(A240547(n), n=1..100) ; # R. J. Mathar, Jun 25 2018
MATHEMATICA
b[2, e_] := 2^(2 e + 1);
b[p_, e_] := p^(2 e - 1)*(p^(e + 1) + p^e - 1);
a[n_] := Times @@ b @@@ FactorInteger[n];
Array[a, 42] (* Jean-François Alcover, Dec 05 2017 *)
PROG
(PARI) a(n) = my(m); if( n<1, 0, forvec( v = vector(4, i, [0, n-1]), m += (0 == norml2(v)%n))); m /* Michael Somos, Apr 07 2014 */
(PARI) a(n) = {my(f = factor(n), res = 1, start = 1, p, e, i); if(n % 2 == 0, res = 1<<(f[1, 2]<<1+1); start = 2); for(i = start, #f~, p = f[i, 1]; e = f[i, 2]; res*=(p^(e<<1-1)*(p^(e+1)+p^e-1))); res} \\ David A. Corneth, Jul 22 2018
CROSSREFS
KEYWORD
nonn,mult
AUTHOR
Laszlo Toth, Apr 07 2014
STATUS
approved