2
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ Do you mean consecutive squares or just random squares? $\endgroup$ – Javi Apr 8 at 14:05
  • $\begingroup$ Random squares sir $\endgroup$ – user662075 Apr 8 at 14:06
2
$\begingroup$

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.

$\endgroup$
0
$\begingroup$

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$.

$\endgroup$
  • $\begingroup$ I am asking for general $n$ squares excluding the trivials. $\endgroup$ – user662075 Apr 8 at 14:12
  • $\begingroup$ Don't forget Lagrange's four-square theorem: that every natural number can be represented as the sum of four integer squares. Though this does not appear to be what the OP is asking, mind you. $\endgroup$ – Mr Pie Apr 8 at 14:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy