Show that an integer of the form $8k + 7$ cannot be written as the sum of three squares.

Note that $x^2\equiv (-x)^2\pmod 8$. So the squares mod $8$ are $0^2=0$, $1^2=1$, $2^2=4$ and $3^2=1$. It is evident that three of these numbers cannot add up $7$.


You get a little bonus: $x^2 + y^2 + z^2$ can be even with two of the variables odd. However, $x^2 + y^2 + z^2$ cannot be divisible by $4$ unless all three of $x,y,z$ are even. So, Assume $x^2 + y^2 + z^2 \equiv 28 \pmod {32}.$ It follows that $x,y,z$ are even, and we get $(x/2)^2 + (y/2)^2 + (z/2)^2 \equiv 7 \pmod 8.$ This is a contradiction, so the sum of three squares cannot be $28 \pmod {32}.$ Do it again, the sum cannot be $112 \pmod {128}.$ And induction...the traditional way to write this is $$ x^2 + y^2 + z^2 \neq 4^k \cdot (8n+7). $$ On the other hand, every other positive integer $m$ can be written as $m=x^2 + y^2 + z^2$ with integer variables. Gauss.