A100876 Least number of squares that sum to prime(n).
2, 3, 2, 4, 3, 2, 2, 3, 4, 2, 4, 2, 2, 3, 4, 2, 3, 2, 3, 4, 2, 4, 3, 2, 2, 2, 4, 3, 2, 2, 4, 3, 2, 3, 2, 4, 2, 3, 4, 2, 3, 2, 4, 2, 2, 4, 3, 4, 3, 2, 2, 4, 2, 3, 2, 4, 2, 4, 2, 2, 3, 2, 3, 4, 2, 2, 3, 2, 3, 2, 2, 4, 4, 2, 3, 4, 2, 2, 2, 2, 3, 2, 4, 2, 4, 3, 2, 2, 2, 4, 3, 4, 4, 3, 3, 4, 2, 2, 3, 2, 3, 2, 3, 2, 3
Offset: 1
Keywords
Examples
a(2)=3 because 3=1^2+1^2+1^2; a(3)=2 because 5=1^2+2^2; a(4)=4 because 7=2^2+1^2+1^2+1^2.
Crossrefs
Cf. A002828 (least number of squares needed to represent n).
Programs
-
Mathematica
SquareCnt[n_] := If[SquaresR[1, n] > 0, 1, If[SquaresR[2, n] > 0, 2, If[SquaresR[3, n] > 0, 3, 4]]]; Table[p = Prime[n]; SquareCnt[p], {n, 150}] (* T. D. Noe, Jan 10 2005, revised Sep 27 2011 *)
Extensions
More terms from T. D. Noe, Jan 10 2005
Comments