Show that $x^2+y^2+z^2=999$ has no integer solutions

Using congruences . . .

Odd squares are always $1 \pmod 8$, hence also $1 \pmod 4$.

Even squares are always $0 \pmod 4$, hence either $0 \text{ or } 4 \pmod 8$.

Since $x^2 + y^2 + z^2$ is odd, either $x,y,z$ are all odd, or exactly one of $x,y,z$ is odd.

If $x,y,z$ are all odd, then $x^2 + y^2 + z^2 \equiv 3 \pmod 8$, contradiction, since $999 \equiv 7 \pmod 8$.

If exactly one of $x,y,z$ is odd, then $x^2 + y^2 + z^2 \equiv 1 \pmod 4$, contradiction, since $999 \equiv 3 \pmod 4$.


My immediate solution was the same as Jorge Fernández Hidalgo, using $\bmod 8$ limits, but carrying on from your sticking point (and trusting your work to that point):

$$k_1^2+k_2^2+k_3^2+k_1+k_2+k_3 = 249 \\ (k_1^2+k_1) + (k_2^2+k_2)+(k_3^2+k_3) = 249 \\ k_1(k_1+1) + k_2(k_2+1)+k_3(k_3+1) = 249 \\ $$ and we have three even terms summing to an odd number, which cannot therefore exist.


This is impossible because the number is congruent to $-1\bmod 8$.

Notice that squares are only $1,4$ and $0\bmod 8$.


In fact there is a theorem by Legendre that say that a number is not the sum of three squares if and only if it is of the form $4^a(8b-1)$. (the other direction is the tough one).