How to show that if $9n^2=a^2+b^2$, $a$ and $b$ are multiples of $3$ To be honest, I don't know where to start with this problem:
Let $n\in \mathbb{N}$. Prove that if $9n^2$ is the sum of two perfect squares $(a^2,b^2)$, then $a$ and $b$ are multiples of $3$.
 A: Taking $9n^2=a^2+b^2$ modulo $3$, we get $$0\equiv a^2+b^2\pmod{3}$$
Now, mod $3$, we have $0^2\equiv 0, 1^2\equiv 1, 2^2\equiv 1$.  The only way two of these sum to $0$ is $0+0$, so $a^2,b^2$ are both equivalent to $0$ mod $3$.
Hence, $3|a^2$ and $3|b^2$.  However, $3$ is prime, so in fact $3|a$ and $3|b$.
A: If one of them is not, say wlog $ a $, then $ a^2 + b^2 \equiv 0 \pmod{9} $, and $ (b/a)^2 \equiv -1 \pmod{9} $ so that $ b/a $ has order $ 4 $ in the group $ (\mathbf Z/9 \mathbf Z)^{\times} $ of order $ 6 $, contradicting Lagrange's theorem.
A: To clarify on vadim's answer after concluding that $$\cases{0^2=0\equiv 0\mod3 \\1^2=1\equiv 1\mod3 \\2^2=4\equiv 1\mod3  }$$
we can make a table of all combinations:
$$\begin{array}{|cc|cc|}\hline a(mod3)&b(mod3)&a^2(mod3)&b^2(mod3)\\\hline
0&0&0&0\\0&1&0&1\\0&2&0&1\\1&0&1&0\\1&1&1&1\\1&2&1&1\\2&0&1&0\\2&1&1&1\\2&2&1&1\\\hline\end{array}$$
we can see that the only way to sum to something divisible by 3 is the first, where both combinations are $0\mod 3$
A: Logically speaking, $$9n^2 = a^2 + b^2 \iff \left({a\over3}\right)^2 + \left({b\over3}\right)^2 = n^2.$$ It is clear that $n^2 \in \mathbb Z$, but because $a^2, b^2$ are perfect squares, then $a,b,n\in\mathbb Z$. Can you see where to take it from here?  
