# Integers which are the sum of non-zero squares

Lagrange's four-square theorem states that every natural number can be written as the sum of four squares, allowing for zeros in the sum (e.g. $6=2^2+1^2+1^2+0^2$). Is there a similar result in which zeros are not allowed in the sum? For example, does there exist $n\in\mathbb{N}$ such that every natural number greater than $n$ can be written as the sum of five non-zero squares, or six non-zero squares, for example?

• Primes of the form $4k+1$ can be represented as $a^2+b^2$... – draks ... Aug 26 '15 at 10:43
• Try this  Table[PowersRepresentations[m, 5, 2], {m, 1, 100}]  at W|A...looks like for $n>33$ you also always have five non-zero squares in your sum... – draks ... Aug 26 '15 at 11:07

This question is answered in "Introduction to Number Theory" by Niven, Zuckerman& Montmogery (pp.318-319 of the fifth edition). I summarize their proof below.

Every integer $\geq 34$ is a sum of five positive squares (while $33$ is not). The number five is optimal, because the only representation of $2^{2r+1}$ as a sum of four squares is $0^2+0^2+(2^r)^2+(2^r)^2$ (easy exercice by induction on $r$).

One can check by hand by all the numbers between $34$ and $169$ are sums of five positive squares. Now, let $n\geq 169$ and let us show that $n$ is a sum of five positive squares.

We know that $n-169$ is a sum of four not necessarily positive squares, $n-169=x_1^2+x_2^2+x_3^2+x_4^2$ and we can assume $x_1 \leq x_2 \leq x_3 \leq x_4$.

If $x_1>0$, writing $n=13^2+x_1^2+x_2^2+x_3^2+x_4^2$ we are done. So assume $x_1=0$.

If $x_2>0$, writing $n=5^2+12^2+x_2^2+x_3^2+x_4^2$ we are done. So assume $x_2=0$.

If $x_3>0$, writing $n=3^2+4^2+12^2+x_3^2+x_4^2$ we are done. So assume $x_3=0$.

If $x_4>0$, writing $n=2^2+4^2+7^2+12^2+x_4^2$ we are done. So assume $x_4=0$.

So now all the $x_i$ are zero, and $n=169=5^2+6^2+6^2+6^2+6^2$. This concludes the proof.

• Is it straightforward, from here, to compute the number of ways that a number can be represented as a sum of five non-zero squares? In particular, I have been thinking of starting the question: how can one find the number, say $r_4^{*}(n)$, of ways to express a given integer $n$ as the sum of four non-zero squares? – user385459 Feb 19 '18 at 10:19
• @user385459 I do not know. It does not seem straightforward to convert this existence proof into a counting method. – Ewan Delanoy Feb 19 '18 at 11:21