$3\nmid a,b \in \mathbb{Z} \implies a^2+b^2$ is not perfect square 
Question: We want to show that if $3\nmid a,b \in \mathbb{Z} \implies a^2+b^2$ is not perfect square of an integer.

Answer: We have:


*

*$3\nmid a \iff a\neq3k,\ \forall k \in \mathbb{Z}$

*$3\nmid b \iff b\neq3l,\ \forall l \in \mathbb{Z}$


From this and the devision algorithm we have:


*

*$a=3q_1+r_1,$ with $1 \leq r_1 \leq2$ for some $\ q_1,r_1\in\mathbb{Z}$

*$b=3q_2+r_2,$ with $1 \leq r_2 \leq2$ for some $\ q_2,r_2\in\mathbb{Z}$
So, there are $4$ possible cases. I will do only the first, because I don't know if I work correctly: $$a=3q_1+1,\ b=3q_2+1$$
Lets assume that $a^2+b^2$ is perfect square of a random number $n$.
Then, $a^2+b^2=(3q_1+1)^2+(3q_2+1)^2=[3(q_1+q_2)]^2+6(q_1+q_2)+2=n^2$, and if $q_1+q_2=x$ we can say that:
$$(3x)^2+6x+2=n^2 \iff (3x+1)^2+1=n^2$$
My question is can we say now that we have contradiction? And why?
Thank you.
 A: So you showed that $a^2+b^2$ is a multiple of $3$ plus $2$. Can this happen? What happens when you square $3k$ or $3k\pm 1$?
A: we have $$x\equiv 0,1,2\mod 3$$ and after squaring we get $$x^2\equiv 0,1\mod 3$$
A: You can continue.  Let $3x + 1$ = $m$ so you have $m^2 + 1 = n^2$ or two consecutive integers are both squares.  That seems wrong somehow. But we must prove it.  
which we can
Notice there are no integers between $n$ and $n+1$. So there are no squares between $n^2$ and $n^2 + 2n + 1$.  So if $n^2 < n^2 + 1 = m^2 \le n^2 + 2n + 1$ that is only possible if $n^2 + 1 = n^2 + 2n +1$ which is only possible if $n=0$.  but we assumed $3\not \mid n$.
But it might be easier to do it directly.
$a = 3k + r_1; b = 3j + r_2;$ and $m = 3l + q$ and 
$a^2 + b^2 = m^2 \implies 9(k^2 + j)^2 + 6(kr_1 + jr_2) + r_1^2 + r_2^2 = 9l^2 + 6l + q^2$  or
$r_1^2 + r_2^3 \equiv q^2 \mod 3$
or $\{1,2\}^2 + \{1,2\}^2 \equiv \{0,1,2\}^2 \mod 3$
so $\{1,4\} + \{1,4\} \equiv \{0,1,4\} \mod 3$
so $\{2,5,8\} \equiv \{0,1 , 4\} \mod 3$
so $2 \equiv \{0,1\} \mod 3$ which is impossible.
And that would be a lot less of a headache if you you used $-1, 0 , + 1$ rather than $0,1 ,2$.
The $a = 3k \pm 1$ and $b = 3j \pm 1$ and $m = 3l \pm 1$ or $ 3l$.
So $a^2 + b^2 = 9(k^2 + j^2) \pm 6(j+k) + 1 + 1 \equiv 2 \mod 3$ while
$m^2 = 9l^2 \pm 6l +\{0, 1\}\equiv 0, 1 \mod 3$.  A contradiction.
