TITLE: Show that an integer of the form $8k + 7$ cannot be written as the sum of three squares.
QUESTION [5 upvotes]: I have figured out a (long, and tedious) way to do it. But I was wondering if there is some sort of direct correlation or another path that I completely missed.
My attempt at the program was as follows: 
A number of the form, $8k + 7 = 7 (mod 8)$. That is, we are looking for integers a, b, c such that $a^2 + b^2 + c^2 = 7 (mod 8)$. 
LONG and TEDIOUS way:
$$(8k)^2 = 0 (mod 8)$$
$$(8k+1)^2 = 1 (mod 8)$$
$$(8k+2)^2 = 4 (mod 8)$$
$$(8k+3)^2 = 1 (mod 8)$$
$$(8k+4)^2 = 0 (mod 8)$$
$$(8k+5)^2 = 1 (mod 8)$$
$$(8k+6)^2 = 4 (mod 8)$$
$$(8k+7)^2 = 1 (mod 8)$$
That is, using three of these modulo there is no way to arrive at 
$$a^2 + b^2 + c^2 = 7 (mod 8)$$

REPLY [0 votes]: A variation:
Let $n = 8k + 7 = x^2 + y^2 +z^2$.
Then $n \equiv 3 \pmod 4$. Every square is congruent to $0$ or $1$ mod $4$, so $x^2, y^2, z^2 \equiv 1 \pmod 4$ for these numbers to add up to $ 3 \bmod 4$. Then $x, y, z$ are odd.
One checks immediately that $(\pm 3)^2 \equiv 1 \pmod 8, (\pm 1)^2 \equiv 1 \pmod 8$, which accounts for all odd numbers, so $n = x^2 + y^2 +z^2 \equiv 3 \pmod 8$. But this contradicts $n \equiv 7 \pmod 8$.
This is only a speedup up if you think it's faster to reduce mod $4$ to learn that you don't have to calculate $(\pm 2)^2 \bmod 8$ and $4^2 \bmod 4$.
{"set_name": "stack_exchange", "score": 5, "question_id": 779784}