<s>[INST] Proving that $a,b$ are even integers I'm trying to prove the following theorem:

Let $a,b\in\mathbb{Z}$ . Then  $$a^{2}+b^{2}\equiv0\pmod 4 \iff a \;\text{and}\; b\;\text{are even}$$

I always struggle to prove some number is odd or even. How to prove it?
I thought of using the $(a+b)^2=a^2+2ab+b^2$ formula but not sure how.
 [/INST] $$a^{2}+b^{2}\equiv0\pmod 4 \iff(a+b)^2-2ab\equiv 0\pmod{4}.$$
If both $a$ and $b$ are odd, then:
$$\begin{align}a+b\equiv 0\pmod{2} &\Rightarrow (a+b)^2\equiv 0\pmod{4}, \text{but}\\
2ab\equiv 0 \pmod{2} &\Rightarrow \qquad 2ab\not\equiv 0\pmod{4}\end{align}$$
If $a$ is odd and $b$ is even, then:
$$\begin{align}2ab&\equiv 0 \pmod{4}, \text{but}\\
a+b\not\equiv 0\pmod{2} \Rightarrow (a+b)^2&\not\equiv 0\pmod{4}\end{align}$$
Finally, if $a$ and $b$ are even, then:
$$\begin{align}a+b\equiv 0\pmod{2} \Rightarrow (a+b)^2&\equiv 0\pmod 4\\
2ab&\equiv 0\pmod 4\end{align}$$
</s>