I was looking for numbers who can be expressed as sum of exactly four squares and not less. And I think I have found them. They are all the integers of the form


I have no idea how to prove this statement and I wonder if ALL the numbers which need four squares are this kind of numbers.


Thanks to the comments and the answer the statement can be more precise

A number can be expressed as the sum of four squares and not less if and only if it has the form


  • 4
    $\begingroup$ Make that $4^n(7+8k)$. This is a well-known, but very deep, theorem of Gauss. $\endgroup$ – Lord Shark the Unknown Jul 14 '17 at 12:15
  • 2
    $\begingroup$ See Legendre's three square theorem and Lagrange's four square theorem together, keeping in mind $0^2$ is allowed. And if anyone is still wondering about $178$ (it was an issue raised in at least two separate comments before they were deleted), we have $12^2 + 5^2 + 3^2$ or $13^2 + 3^2$. $\endgroup$ – Arthur Jul 14 '17 at 12:17
  • $\begingroup$ Thank you for the correction. I reviewed my notes and it was just a typo. But I did not know that the property was known. I am glad anyway to have rediscover it by myself :) $\endgroup$ – Raffaele Jul 14 '17 at 18:08
  • $\begingroup$ @Arthur Legendre's theorem page looks quite wrong on wikipedia since the OEIS page and my result are about FOUR squares and not three. What do you think about? $\endgroup$ – Raffaele Sep 5 '17 at 8:59
  • $\begingroup$ @Raffaele No, I stand by what I said. Lagrange's four square theorem says that any number can be written as the sum of four squares (allowing for $0^2$). Legendre says that the number can be written as the sum of three squares iff it is not of the form $4^n(7+8k)$. Thus the numbers that can be written as a sum of four squares, but not as a sum of three are exactly the ones excluded by Legendre. $\endgroup$ – Arthur Sep 5 '17 at 9:04

At least it is not hard to see that $4^n(7+8k)$ cannot be written as sum of three squares: $a^2+b^2+c^2\equiv m\pmod 4$ where $m$ is the number of odd squares on the left. Hence for $n\ge 1$, any representation of $4^n(7+8k)$ must use three even squares. But then this corresponds to the representation $4^{n-1}(7+8k)=(a/2)^2+(b/2)^2+(c/2)^2$ with smaller $n$. We are thus reduced to the case $n=0$, i.e., $7+8k=a^2+b^2+c^2$. By the above argument, $a,b,c$ must be odd. As odd squares are $\equiv 1\pmod 8$, we obtain $7+8k\equiv 3\pmod 8$, contradiction.

The other direction is less trivial (see comments about Legendre's theorems)


Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.