%I #38 Mar 11 2023 11:34:23
%S 1,6,6,30,6,30,30,54,6,102,30,78,30,78,54,150,6,102,102,126,30,270,78,
%T 150,30,150,78,318,54,174,150,198,6,390,102,270,102,222,126,390,30,
%U 246,270,270,78,510,150,294,30,390,150,510,78,318,318,390,54,630,174,366
%N Number of integer solutions to x^2+y^2+z^2 = n^2, allowing zeros and distinguishing signs and order.
%C Hurwitz found a formula for a(n). See the paper by Olds.
%H T. D. Noe, <a href="/A016725/b016725.txt">Table of n, a(n) for n = 0..10000</a>
%H Michael Gilleland, <a href="/selfsimilar.html">Some Self-Similar Integer Sequences</a>
%H Werner Hürlimann, <a href="https://cs.uwaterloo.ca/journals/JIS/VOL18/Huerlimann/huerli6.html">Exact and Asymptotic Evaluation of the Number of Distinct Primitive Cuboids</a>, Journal of Integer Sequences, Vol. 18 (2015), Article 15.2.5.
%H Jean Lagrange, <a href="http://www.numdam.org/item?id=SDPP_1972-1973__14_1_A1_0">Décomposition d'un entier en somme de carrés et fonction multiplicative</a>, Séminaire Delange-Pisot-Poitou. Théorie des nombres, 14 no. 1 (1972-1973), Exp. No. 1, 5 p.
%H C. D. Olds, <a href="http://projecteuclid.org/euclid.bams/1183503695">On the representations, N_3(n^2)</a>, Bull. Amer. Math. Soc. 47 (1941), 499-503.
%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/SumofSquaresFunction.html">Sum of Squares Function</a>
%F a(n) = 6 * b(n) if n>0 where b(n) is multiplicative with b(2^e) = 1, b(p^e) = p^e if p == 1 (mod 4), b(p^e) = p^e + 2 * (p^e - 1) / (p - 1) if p == 3 (mod 4). - _Michael Somos_, Nov 18 2011
%F a(n) = A005875(n^2).
%F a(n) = [x^(n^2)] theta_3(x)^3, where theta_3() is the Jacobi theta function. - _Ilya Gutkovskiy_, Apr 20 2018
%e 1 + 6*x + 6*x^2 + 30*x^3 + 6*x^4 + 30*x^5 + 30*x^6 + 54*x^7 + 6*x^8 + ...
%p for n from 0 to 60 do s:=0: for x from -n to n do for y from -n to n do for z from -n to n do if (x^2+y^2+z^2) = n^2 then s:=s+1 fi od od od: printf("%d, ",s) od: # C. Ronaldo (aga_new_ac(AT)hotmail.com), Dec 13 2004
%t SquaresR[3, Range[0,100]^2]
%o (PARI) {a(n) = if( n<1, n==0, polcoeff( sum( k=1, n, 2 * x^k^2, 1 + x * O(x^n^2))^3, n^2))} /* _Michael Somos_, Nov 18 2011 */
%o (PARI) {a(n) = local(A, p, e); if( n<1, n==0, A = factor(n); 6 * prod( k=1, matsize(A)[1], if( p = A[k, 1], e = A[k, 2]; if( p==2, 1, p^e + if( p%4 == 1, 0, 2 * (p^e - 1) / (p - 1))))))} /* _Michael Somos_, Nov 18 2011 */
%Y Cf. A005875.
%Y Column k=3 of A302996.
%K nonn,look
%O 0,2
%A csvcjld(AT)nomvst.lsumc.edu
%E Revised description from C. Ronaldo (aga_new_ac(AT)hotmail.com), Dec 13 2004