About sum of n squares The theorems about sum of two, three and four squares are very well known, but, i am just asking out of curiosity, is there any kind of algorithm or formula to determine whether a number is a sum of $n$ squares? I mean for a specific $n$, is there some relation between that algorithm and the sum?
Edit: I understand i was not precise.... I mean leaving 0s and not specifically 2 or 3 squares.
 A: Once you know that any number is the sum of $4$ squares you know that it is the sum of $n$ squares for $n \gt 4$ because you can add as many copies of $0^2$ as you need.  
Added:  if you want to express $N$ as the sum of $n$ squares without using $0$ the big problem comes if $N$ is too small.  Clearly you need $N \ge n$.  The natural thing to do is start with $n-4\ 1$'s and express $N-n+4$ as a sum of four squares Because you cannot express $1,2,3,5,6,8,9 \ldots$ as a sum of four nonzero squares you cannot express $n+1,n+2,n+3,\ldots$ as a sum of $n$ squares.  I did not find this sequence in OEIS.  This answer shows that every natural greater than $34$ is the sum of five nonzero squares.  We can then say that for $n \gt 4,$ all numbers greater than $n+29$ are the sum of $n$ nonzero squares.
A: A corollary of Fermat's two-squares theorem is:

An integer greater than $1$ can be written as a sum of two squares if and only if its prime decomposition contains no prime congruent to $3 \mod 4$ raised to an odd power.

Legendre's three-square theorem states:

A natural number $n$ can be represented as the sum of three squares if and only if it is not of the form $n = 4 a   ( 8 b + 7 ) $  for integers $a$ and $b$. 

