It seems to be very well known that $33$ is the largest integer with zero representations as a sum of five nonzero squares. So it seems reasonable to me that as we go higher and higher, numbers have more and more representations as sums of five nonzero squares, and maybe there is a threshold above which all numbers have at least two such representations.

My question is, what is the largest integer with only one representation as a sum of five nonzero squares?


4 Answers 4


OK, I'll write this down as a new answer because it

  • uses Jyrki Lahtonen's idea to use the Three square theorem instead of the four square tehorem
  • uses Jyrki's method of distinguishing by the remainder $n\pmod 8$
  • uses my idea of subtracting numbers that can be written as different sums of squares to eat up zeroes.
  • most of all, it produces the exact threshold with virtually no additional work!

The "main trick" is as follows: Assume $$ A=a^2+b^2=c^2+d^2+e^2=f^2+g^2+h^2+i^2$$ with $a,\ldots ,i\in\mathbb N$. Then if $n>A$ and $n\not\equiv A\pmod 8$ and $n\not\equiv A-1\pmod 8$, we can write $n-A$ as sum of three squares by the three squares theorem. Depending on how many of these three squares are zero (not all of them because $n-A>0$), we have $$n-A=\begin{cases}u^2&\text{or}\\u^2+v^2&\text{or}\\u^2+v^2+w^2\end{cases}$$ with $u,v,w\in\mathbb N$ and hence obtain a representation of $n$ as sum of five nonzero squares: $$n=\begin{cases}f^2+g^2+h^2+i^2+u^2&\text{or}\\ c^2+d^2+e^2+u^2+v^2&\text{or}\\ a^2+b^2+u^2+v^2+w^2.\end{cases} $$

Theorem. Every integer greater than $60$ has at least two distinct representations as sum of five nonzero squares.

Proof. Let $n\in\mathbb N$ with $n>61$ (sic!) and write $n=8r+k$ with $0\le k\le 7$.

Consider first the case that $k\in\{0,1,2,3,6,7\}$. As $61\equiv 5\pmod 8$, the observation $$\tag1\begin{align} 61=6^2+5^2=6^2+4^2+3^2&=5^2+4^2+4^2+2^2\\ &=7^2+2^2+2^2+2^2 \end{align}$$ allows us to apply the main trick and obtain a representation $$\tag2 n=a^2+b^2+c^2+d^2+e^2$$ of $n$ as sum of five nonzero squares. In fact, if four of the summands in $(2)$ add up to $61$, we already obtain two distinct representations, so we assume that $61$ is formed by either two or three of the summands in $(2)$. As also $53\equiv 5\pmod 8$ and $$\tag353 = 7^2+2^2 = 6^2+4^2+1^2=6^2+3^2+2^2+2^2,$$ we obtain another representation of $n$. If this is a different representation, we are done. Otherwise we need to check how the summands from $(1)$ and $(3)$ can occur in $(2)$ and we distinguish cases depending on the summands these two sub-sums have in common:

  • None: Then four or five of the summands in $(2)$ add up to $61+53=114$. Replacing these with $114=9^2+5^2+2^2+1^2=9^2+4^2+3^2+2^2+1^2$, we therefore obtain a distinct representation (it is distinct because the number of $9^2$'s occuring differs)
  • $6^2$: Then four or five squares add up to $61+53-36=78$. Replacing these per $78=8^2+2^2+2^2 +1^2=6^2+6^2+2^2+2^2$ gives us a distinct representation (distinct because the number of $6^2$'s differs).
  • $4^2$: A summand $4^2$ occurs in $(3)$ only in $6^2+4^2+1^2$ and in $(1)$ only in $6^2+4^2+3^2$ (remember that the case of four summands in $(1)$ has already been dealt with). Thus we we can refer to the case "$6^2+4^2$" below.
  • $3^2$: Again, we conclude that $6^2$ is also a common summand, so see "$6^2+3^2$" below.
  • $6^2+4^4$: We conclude that $$\tag4n=\rlap{\underbrace{3^2+6^2+4^2}_{61}}\hphantom{3^2+}\overbrace{\hphantom{6^2+4^2}+1^2}^{53}+a^2$$ for some $a\in\mathbb N$. Since $a^2\bmod 8$ is in $\{0,1,4\}$, we conclude that $k\in\{2,6,7\}$. If $a=1$, we have the two representations $n=63=6^2+4^2+3^2+1^2+1^2=5^2+4^2+3^2+3^2+2^2$. If $a>1$, then $n>65$ and as $65\equiv 1\pmod 8$ and $k\notin\{0,1\}$, we use the main trick with $$\tag5 65 = 8^2+1^2 = 6^2+5^2+2^2=6^2+4^2+3^2+2^2$$ to obtain a representation of $n$. This can conincide with the representation $(4)$ only as follows (with alternate representations exhibited): $$\begin{align}n&= 6^2+4^2+3^2+\overbrace{1^2+\underset{=a^2}{8^2}}^{65}=10^2+3^2+3^2+2^2+2^2\quad\text{or}\\ n&= 1^2+\overbrace{6^2+4^2+3^2+\underset{=a^2}{2^2}}^{65}=\hphantom{1}4^2+4^2+4^2+3^2+3^2.\end{align}$$
  • $6^2+3^2$: This can happen only if $n=\rlap{\underbrace{4^2+6^2+3^2}_{61}}\hphantom{4^2+}\overbrace{\hphantom{6^2+3^2}+2^2+2^2}^{53}=69$, but then also $n=7^2+3^2+3^2+1^2+1^2$.

This completes the proof for the case $k\in\{0,1,2,3,6,7\}$. Assume now that $k\in\{ 4,5\}$. From $$\begin{align} 50&=5^2+5^2=5^2+4^2+3^2=4^2+4^2+3^2+3^2\\ &=7^2+1^2\hphantom{{}=5^2+4^2+3^2}=6^2+3^2+2^2+1^2\end{align}$$ with $50\equiv 2\pmod 8$ we see that the main trick can be applied and we obtain a representation of $n$ as sum of five nonzero squares. Unless what we obtain is $n=5^2+4^2+3^2+a^2+b^2$, we already get two distinct representations and are done. Doing the same with $$26 = 5^2+1^2 = 4^2+3^2+1^2=3^2+3^2+2^2+2^2$$ (where also $26\equiv 2\pmod 8$), we get another representation unless the following coincidence happens:

$$\tag6n=\rlap{\underbrace{4^2+3^2+5^2}_{50}}\hphantom{4^2+3^2+}\overbrace{\hphantom{5^2}+1^2}^{26}+a^2=\rlap{\underbrace{5^2+4^2+3^2}_{50}}\hphantom{5^2+}\overbrace{\hphantom{4^2+3^2}+1^2}^{26}+a^2. $$ If $a$ is even, we get $n\equiv 3\pmod 4$ contradicting $k\in\{4,5\}$; hence $a$ is odd. As $n>61$, we conclude $a\ge 5$, hence $n>74$ and from $$ 74 = 7^2+5^2=7^2+4^2+3^2=6^2+6^2+1^2+1^2$$ (with $74\equiv 2\pmod 8$ as well) we obtain another representation unless the following conincidence occurs: $$ n= 4^2+3^2+1^2+\overbrace{5^2+\underset{=a^2}{7^2}}^{74}=5^2+1^2+\overbrace{4^2+3^2\underset{=a^2}{7^2}}^{74}=100,$$ but then we have the second representation $$n = 9^2+4^2+1^2+1^2+1^2.$$

In summary, we have shown that for all $n>61$ there exist at least two distinct representations of $n$ as sum fo five nonzero squares. From $$ 61 = 7^2+3^2+1^2+1^2+1^2 = 5^2+5^2+3^2+1^2+1^2$$ we see that the result is in fact true for all $n>60$. $_\square$

On the other hand, one verifies that the representation $$\tag7 60=5^2+4^2+3^2+3^2+1^2$$ is unique, hence that the bound $60$ in the theorem is sharp, either by exhaustive search or as follows:

Assume $60=a^2+b^2+c^2+d^2+e^2$ with $a\ge b\ge c\ge d\ge e$. Then $4\le a\le 7$ because $5\cdot 3^2<60<8^2$. If $a=7$, then $60-7^2-3\ge b^2\ge \frac{60-7^2}{4}$ implies $b=2$, but $60-7^2-2^2=7$ cannot be written as sum of three squares. If $a=6$, then $60-6^2-3\ge b^2\ge \frac{60-6^2}{4}$ implies $b=3$ or $b=4$, but $60-6^2-4^2=8$ and $60-6^2-4^2=15$ cannot be written as sum of three nonzero squares. If $a=4$ then also $b=4$ because $4^2+4\cdot 3^2<60$ and $c=4$ because $2\cdot4^2+3\cdot 3^2<60$; but $60-3\cdot 4^2=12$ is not the sum of two squares. Remains $a=5$, $b^2+c^2+d^2+e^2=35$. From $4\cdot 3^2>35$ we conclude $e\le 2$. Then from $3\cdot 3^2+2^2<35$, we conclude $b\ge 4$. If $b=5$ then $10=c^2+d^2+e^2$ is written as sum of three nonzero squares, which is not possible. Therefore $b=4$, and we have to write $19$ as sum of three, necessarily odd, squares. The only solution leads to $(7)$.

Generalization. Let $r(n)$ denote the number of representations of $n$ as sum of five nonzero squares.

  • If $n>5408$ then $r(n)\ge \lfloor\frac18\sqrt{n-101}\rfloor$; if additionally $n\not\equiv 1\pmod 8$ then $r(n)\ge\frac{n}{720}$.
  • If $k\ge10$ and $n\ge 64k^2+101$ then $r(n)\ge k$.
  • If $k\ge 7$, $n>720(k-1)$, and $n\not\equiv 1\pmod 8$, then $r(n)\ge k$.

Proof. As pointed out by Jyrki Lahtonen in his answer, unless $n\equiv 1\pmod 8$, we obtain a representation of $n=a^2+b^2+c^+d^2+e^2$ as sum of five nonzero squares for each choice $(a,b)$ with $a^2,b^2<\frac n2$ and $a\bmod 4$, $b\bmod 4$ have a prescribed value (depending on $n\bmod 8$). For $a$ (and also for $b$) there are at least $\left\lfloor\frac14\sqrt{\frac{n-1}2}\right\rfloor$ choices. Each representation is found repeatedly at most $5\cdot 4$ times (the ways $a$ and $b$ can be picked among the five summands). This gives us at least $$ \tag8r(n)\ge\left\lceil\frac1{20}\left\lfloor \frac14\sqrt{\frac{n-1}2}\right\rfloor^2\right\rceil\sim\frac{n}{640}$$ representations. To make the "$\sim$" more explicit, one verifies $$r(n)\ge\begin{cases}\frac n{784}&\text{if $n\ge1000$ (with $n=1568$ being critical)},\\ \frac n{720}&\text{if $n\ge3873$ (with $n=7200$ being critical)},\\ \frac n{648}&\text{if }n>10^6. \end{cases} $$

We now come to the case $n\equiv 1\pmod 8$. If $a\equiv 0\pmod 4$ and $a^2<n-100$, then $n-10^2-a^2>0$ and $\equiv 5\pmod 8$ can be written as sum of up to three nonzero squares. One of these squares must be $\equiv 1\pmod 8$, one must be $\equiv 4\pmod 8$, and the third square, if any, is $\equiv 0\pmod 8$. Hence either $$\tag{9a}n=8^2+6^2+a^2+b^2+c^2\text{ with $b\equiv 1\pmod 2, c\equiv 2\pmod 4$}$$ or $$\tag{9b}n=10^2+a^2+b^2+c^2+d^2\text{ with additionally $d\equiv 0\pmod 4$}.$$ Let us agree that we use $(9a)$ only if for the given choice of $a$ no representation of type $(9b)$ exists. There are at least $\left\lfloor \frac14\sqrt{n-101}\right\rfloor$ choices for $a$. Distinct $a$ can never lead to the same type $(9a)$ representation (only $a$ is a multiple of $4$); distinct $a$ can lead to the same representation of type $(9b)$ only if $a\leftrightarrow d$ are swapped; by our preference for $(9b)$ over $(9a)$, it is not possible for two choices of $a$ leading to the same representation where one is of type $(9a)$ and the other is of type $(9b)$. We conclude that $$ \tag{10}r(n)\ge\frac 12\left\lfloor \frac14\sqrt{n-101}\right\rfloor\ge \left\lfloor \frac18\sqrt{n-101}\right\rfloor.$$ It is clear that this bound is lower than the one found in $(8)$ if $n$ is large enough. One verifies (standard estinmates for floor/ceiling will work, but, hey, just look at the graphs of the functions) that the largest $n$ where the bound $(8)$ is lower than the bound $(10)$ is $n=5408$, hence the first claim. The other claims follow by solving the inequalities for $n$. $_\square$

Remark: Donovan Johnson (2013) reports on OEIS (sequence A080673) that no $n\le 10^6$ with $r(n)=188$ exists. According to the estimate in the generalization, extending the search range up to $2286245$ (where one may restrict to $n\equiv 1\pmod 8$) would prove That no $n$ with $r(n)=188$ exists at all (or find all such $n$). In the proof above I made use only of $10^2=6^2+8^2$. One may find more representations with using more even-sided pythagorean triangles, such as $20^2=12^2+16^2$ or $26^2=24^2+10^2$. While I wanted to avoid the more complex bookkeeping about duplicates, persuing this might show that D. Johnson's finding is sufficient to conclude that $r(n)\ne 188$ for all $n$.


Let $A=7225$ and note that $$\tag1 \begin{align}A&= 85^2\\&=84^2+13^2\\&=84^2+12^2+5^2\\&=84^2+12^2+4^2+3^2,\end{align}$$ but also $$\tag2\begin{align} A&=77^2+36^2\\&=60^2+60^2+5^2\\&=60^2+60^2+3^2+4^2.\end{align}$$ Also let $B=49A$ so that we get corresponding representations to $(1)$ and $(2)$ with all $x^2$ replaced by $(7x)^2$. By Lagrange, we know that every natural number can be written as the sum of up to four nonzero squares. Thus if $n>A$, we apply this to $n-A$ and find that, depending on how many squares we need for $n-A$, we can pick a suitable representation from $(1)$ to obtain a representation of $n$ as sum of five nonzero squares. As we have alternate choices from $(2)$, we obtain a second such representation, unless the representation we found for $n-A$ used four nonzero squares and the only five-square representation for $n$ we find is of the form$$\tag3n=85^2+a^2+b^2+c^2+d^2.$$ If $n>B$, we can repeat the argument and either find two representations of $n$ as sum of five squares, or we find that $$\tag4n=595^2+e^2+f^2+g^2+h^2.$$ But then $(3)$ and $(4)$ are two distinct representations - unless they coincide, i.e. both are in fact $$\tag{3,4} n=85^2+595^2+i^2+j^2+k^2.$$ But then we make use of $1^2+7^2=5^2+5^2$ and find a second representation $$\tag5 n=425^2+425^2+i^2+j^2+k^2.$$ We conclude that all numbers $n>B=354025$ allow at least two representations as sum of five nonzero integers. To determine the smallest bound that can be used in place of $B$ is a finite task and left as exercise to the reader. (And the reader should find that the true threshold is much lower: We have two representations for all $n>60$)

Remark: Encouraged by the numerical finding that the actual threshold is $\ll B$, I made a little search for a better $A$ and found that using $$\begin{align}A:=625&=25^2\\&=7^2+24^2=15^2+20^2\\ &=9^2+12^2+20^2=15^2+12^2+16^2\\ &=9^2+12^2+12^2+16^2=10^2+10^2+13^2+16^2\end{align}$$ and $B:=4A$ together with the observation $25^2+50^2=10^2+55^2$ allows to show (by the very same method as above) that there are two representations for all $n>2500$. This signifiacntly lessens the "manual" work required for finding the true threshold.

Generalization: Now Let $k\ge 0$ and $$\begin{align}A=169 &=13^2\\&=5^2+12^2\\&=3^2+4^2+12^2\\&=1^2+2^2+8^2+10^2. \end{align}$$ Assume that $n>(30k+1)^2A$ has only $k$ representations as sum of five squares. Each of these representations gives us $30$ sums obtained by using one up to four of its summands. There is at least one $m$ with $1\le m\le30k+1$ such that none of these $30k$ sums evaluates to $m^2A$. But then we obtain a new representation of $n$ from applying Lagrange to $n-m^2A$, contradiction. We conclude that all $n>(390k+13)^2$ have at least $k+1$ representations as sum of five nonzero squares.

  • $\begingroup$ I constructed my $A$ from below using the sequence of pythagorean triangles $(3,4,5)$, $(5,12,13)$, $(13,84,85)$ to obtain $(1)$ and then looked for the alternative repesentatons $(2)$. Instad of looking for an "independant" $B$, I wanted to use a multiples that allowed the use of $1^2+7^2=5^2+5^2$ in the end. Better choices of $A$ and $B$ might have helped finding a lower estimate faster .. $\endgroup$ May 28, 2014 at 18:56

It's getting late so I'll post an incomplete answer showing that an integer $\ge70$ can be represented as a sum of five squares in at least two different ways unless $n\equiv1\pmod8$.

The main tools:

  • Three square theorem.
  • An integer $\equiv3\pmod8$ can be represented as a sum of three odd squares (all of which are then non-zero). This is due to Gauss (equivalent to his result that every natural number can be written as a sum of three triangular numbers), and follows from the three square theorem, because the only way for three squares to add up to something $\equiv3\pmod 8$ is for all three squares to be odd. This is because $0,1,4$ are the only quadratic residues modulo $8$
  • Similarly we see that any integer $\equiv6\pmod8$ can be written as a sum of three squares such that the squares in question can only be congruent to $4,1,1$ modulo $8$ respectively. In particular all those must be non-zero.

Let's roll. So I must assume that $n\equiv k\pmod8$ where $k=0,2,3,4,5,6,7$.

$\mathbf{k=0}$: By the second bullet both $n-4-1$ and $n-36-1$ are sums of three odd squares, so assuming $n\ge40$ we are done with this case.

$\mathbf{k=2}$: By the last bullet $n-16-36$ and $n-4-64$ are both sums of a single non-zero even square and two odd squares. Provided that $n\ge70$ we get two representations of $n$ as a sum of three even squares and two odd squares. Because $4,16,36,64$ all appear, the two representations are different.

$\mathbf{k=3}$: All we need to do here is to apply the second bullet to $n-4-4$ and $n-16-16$, so we only need to assume $n\ge35$.

$\mathbf{k=4}$: All we need to do here is to apply the second bullet to $n-16-1$ and $n-64-1$, which we are able to do provided $n\ge 68$. Note that the two representations are distinct, because the sole even squares in them are different.

$\mathbf{k=5}$: If all the numbers $n-1-1$, $n-9-9$, $n-25-25$ are all positive, then by the second bullet they are all sums of three odd squares. Necessarily at least two of the resulting representations of $n$ as a sum of five squares are different, because $1,9,25$ cannot all appear twice among a set of five squares. This case is settled, if $n\ge55$.

$\mathbf{k=6}$: By the last bullet if $n\ge38$, then both $n-4-4$ and $n-16-16$ can be written as sums of an even square $\equiv4\pmod8$ and two odd squares. Again we get two different representations.

$\mathbf{k=7}$: Here we simply apply the second bullet to both $n-4-16$ and $n-36-16$. Again the resulting representations as sums of the prescribed two even squares and some three odd squares are different. This case is thus done, if $n\ge59$.

But the case $k=1$ gives me a headache. Here I cannot overcome the possibility of some of the participating squares becoming zero. One can try and find suitable representation as four squares for both $(n-1)/4$ and $(n-9)/4$, but the number of cases blows up, and it looks like it might lead to further splitting. May be morning (or somebody else!) will be wiser :-(

  • $\begingroup$ It may be better to combine this with Hagen's idea of using a number with several representations with a variable number of terms. Thinking... $\endgroup$ May 28, 2014 at 20:52
  • $\begingroup$ +1 Even though you are still missing the case $\equiv 1\pmod 8$, I am impressed because your $n\ge 70$ is much closer to the true threshold $n\ge61$ than my findings $n\ge 354025$ (or $n\ge2500$ as pointed out in my remark) $\endgroup$ May 28, 2014 at 20:52
  • $\begingroup$ Thanks, @Hagen. May be there is a better mechanism for dealing with the possibility of zeros appearing. Your construction of $A$ is quite inspired! $\endgroup$ May 28, 2014 at 20:57

You may find it interesting to have a glance at this image: http://oeis.org/A025429/graph (Number of partitions of n into 5 nonzero squares). -- see also http://oeis.org/A080673 = largest numbers with exactly n representations as sum of five positive squares.

  • 1
    $\begingroup$ Yay, I got quoted :) $\endgroup$ May 31, 2014 at 16:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .