Prove that if $3\mid(a^2+b^2)$,then $3\mid a$ and $ 3\mid b$ I am trying to prove this by contradiction. So if $3$ doesn't divide $a$ or $3$ doesn't divide $b$, then the remainder is either $1$ or $2$. I am struggling on what to do next. How do I get the remainder of $a^2$ and $b^2$ for these cases?
Any help is greatly appreciated. Thank you!

Assume $a,b$ are not divisible by $3$. Then:
$$a=3m+1 \ \ \text{or} \ \ a=3m+2; \\ 
b=3n+1 \ \ \text{or} \ \ b=3n+2.$$
Note:
$$(3k+1)^2=3(3k^2+2k)+1; \ \ (3k+2)^2=3(3k^2+4k+1)+1.$$
Then:
$$a^2+b^2 \equiv 2 \ (\mod 3).$$
Now assume only one of them is divisible by $3$. Then:
$$a^2+b^2 \equiv 1 \ (\mod 3).$$
Contradiction, hence both $a$ and $b$ must be divisible by $3$.
