login
A000164
Number of partitions of n into 3 squares (allowing part zero).
28
1, 1, 1, 1, 1, 1, 1, 0, 1, 2, 1, 1, 1, 1, 1, 0, 1, 2, 2, 1, 1, 1, 1, 0, 1, 2, 2, 2, 0, 2, 1, 0, 1, 2, 2, 1, 2, 1, 2, 0, 1, 3, 1, 1, 1, 2, 1, 0, 1, 2, 3, 2, 1, 2, 3, 0, 1, 2, 1, 2, 0, 2, 2, 0, 1, 3, 3, 1, 2, 2, 1, 0, 2, 2, 3, 2, 1, 2, 1, 0, 1, 4, 2, 2, 1, 2, 3, 0, 1, 4, 3, 1, 0, 1, 2, 0, 1, 2, 3, 3, 2, 4, 2, 0, 2
OFFSET
0,10
COMMENTS
a(n) = number of triples of integers [ i, j, k] such that i >= j >= k >= 0 and n = i^2 + j^2 + k^2. - Michael Somos, Jun 05 2012
REFERENCES
E. Grosswald, Representations of Integers as Sums of Squares. Springer-Verlag, NY, 1985, p. 84.
LINKS
Hirschhorn, M. D., Some formulas for partitions into squares, Discrete Math. 211 (2000), pp. 225-228.
FORMULA
Let e(n,r,s,m) be the excess of the number of n's r(mod m) divisors over the number of its s (mod m) divisors, and let delta(n)=1 if n is a perfect square and 0 otherwise. Then, if we define alpha(n) = 5*delta(n) + 3*delta(n/2) + 4*delta(n/3), beta(n) = 4*e(n,1,3,4) + 3*e(n,1,7,8) + 3*e(n,3,5,8), gamma(n) = 2*Sum_{1<=k^2<n} e(n-k^2,1,3,4), it follows that a(n) = (1/12)*(alpha(n) + beta(n) + gamma(n)). - Ant King, Oct 15 2010
EXAMPLE
G.f. = 1 + x + x^2 + x^3 + x^4 + x^5 + x^6 + x^8 + 2*x^9 + x^10 + x^11 + x^12 + x^13 + ...
MAPLE
A000164 := proc(n)
local a, x, y, z2, z ;
a := 0 ;
for x from 0 do
if 3*x^2 > n then
return a;
end if;
for y from x do
if x^2+2*y^2 > n then
break;
end if;
z2 := n-x^2-y^2 ;
if issqr(z2) then
z := sqrt(z2) ;
if z >= y then
a := a+1 ;
end if;
end if;
end do:
end do:
a;
end proc: # R. J. Mathar, Feb 12 2017
MATHEMATICA
Length[PowersRepresentations[ #, 3, 2]] & /@ Range[0, 104]
e[0, r_, s_, m_]=0; e[n_, r_, s_, m_]:=Length[Select[Divisors[n], Mod[ #, m]==r &]]-Length[Select[Divisors[n], Mod[ #, m]==s &]]; alpha[n_]:=5delta[n]+3delta[1/2 n]+4delta[1/3n]; beta[n_]:=4e[n, 1, 3, 4]+3e[n, 1, 7, 8]+3e[n, 3, 5, 8]; delta[n_]:=If[IntegerQ[Sqrt[n]], 1, 0]; f[n_]:=Table[n-k^2, {k, 1, Floor[Sqrt[n]]}]; gamma[n_]:=2 Plus@@(e[ #, 1, 3, 4] &/@f[n]); p3[n_]:=1/12(alpha[n]+beta[n]+gamma[n]); p3[ # ] &/@Range[0, 104]
(* Ant King, Oct 15 2010 *)
a[ n_] := If[ n < 0, 0, Sum[ Boole[ n == i^2 + j^2 + k^2], {i, 0, Sqrt[n]}, {j, 0, i}, {k, 0, j}]]; (* Michael Somos, Aug 15 2015 *)
PROG
(PARI) {a(n) = if( n<0, 0, sum( i=0, sqrtint(n), sum( j=0, i, sum( k=0, j, n == i^2 + j^2 + k^2))))}; /* Michael Somos, Jun 05 2012 */
(Python) import collections; a = collections.Counter(i*i + j*j + k*k for i in range(100) for j in range(i+1) for k in range(j+1)) # David Radcliffe, Apr 15 2019
CROSSREFS
Equivalent sequences for other numbers of squares: A000161 (2), A002635 (4), A000174 (5).
Cf. A004215 (positions of zeros), A094942 (positions of ones), A124966 (positions of greater values).
Sequence in context: A178666 A206706 A302354 * A330261 A157746 A349082
KEYWORD
nonn
EXTENSIONS
Name clarified by Wolfdieter Lang, Apr 08 2013
STATUS
approved