If 8 divides $a^2$ + $3b^2$, prove that both a and b are even. Question: Prove that if $a$ and $b$ are integers and 8 divides $a^2$ + $3b^2$, then both a and b are even.
I'm able to prove that 8 divides $a^2$ + $3b^2$ if both $a$ and $b$ are even using the fundamental theorem of arithmetic and expressing 8 as $2^3$, but I'm not sure how to prove that 8 does not divide $a^2$ + $3b^2$ if either $a$ or $b$ is odd or both $a$ and $b$ are odd.

$a^2+3b^2=(a+b)^2+2b^2-2ab.$ Clearly  $2b^2-2ab$ is even. If one of $a$ or $b$ is odd, then $(a+b)^2$ is odd. But then $$ (a+b)^2+2b^2-2ab$$ is the sum of an odd and even number and hence odd. Thus $8$ cannot divide it.
If they are both odd then we have
\begin{align*}
a^2+3b^2&=(2m+1)^2+3(2n+1)^2 \\
&= 4m^2+4m+1+12n^2+12n+3\\
&=4(m^2+3n^2+m+3n+1).
\end{align*}
Let $k= m^2+3n^2+m+3n+1$
If $m,n$ are both even, then $k$ is odd.
If one of $m,n$ is odd, $k$ is again seen to be odd.
Finally, when $m,n$ are both odd, then $k$ is odd again.
$k$ being odd in all cases, we see that $8$ cannot divide the sum, which is a contradiction.
