Two questions in class (mod 8)

Warm-up exercise: Quote:

Show that any square leaves remainder 0, 1 or 4 on division by 8.

Which is better "proof":

- $\displaystyle a_{even}=2k$: $\displaystyle a^2=(2k)^2=4(k^2)= \left\{ \begin{array}{ll}

0\mod{8} & \mbox{; $k_{even}$}\\

4\mod{8} & \mbox{; $k_{odd}$}\end{array} \right.$

$\displaystyle a_{odd}=2k-1$: $\displaystyle a^2=(2k-1)^2=4(k^2-k)+1=1\mod{8}\text{ ; } k_{even} \text{ or } k_{odd} \square$

**or** to write all possible cases in (mod 8) class (as *undefined* helped me here)

- $\displaystyle 0^2\equiv 0 \mod{8}$

$\displaystyle 1^2\equiv 1 \mod{8}$

$\displaystyle \vdots$

$\displaystyle 7^2\equiv 1 \mod{8}\square$

Quote:

Deduce that a sum of 3 squares leaves remainder 0, 1, 2, 3, 4, 5, or 6 on division by 8.

"Obvious" from 1st exercise, but how to write a proof?

Let $\displaystyle n_0\equiv (2k_{even})^2\text{, } n_1\equiv (2k+1)^2\text{ , }n_2\equiv (2k_{odd})^2$ and $\displaystyle (n_x,n_x,n_x)$ be a sum of 3 squares.

Then just write all possible combinations?

$\displaystyle (n_0,n_0,n_0)\equiv 0 \mod{8}$

$\displaystyle (n_0,n_0,n_1)\equiv 1 \mod{8}$

$\displaystyle (n_0,n_1,n_1)\equiv 2 \mod{8}$

$\displaystyle \vdots$

$\displaystyle (n_1,n_2,n_2)\equiv 1 \mod{8}$

$\displaystyle (n_2,n_2,n_2)\equiv 4 \mod{8}\square$