Prove that the square of an integer $a$ is of the form $a^2=3k$, or $a^2=3k+1$, where $k\in \mathbb{Z} $ Here's my attempt to prove this. I'm not sure about it, but i hope i'm correct.
Let $a=λ, λ\in \mathbb{Z}$. Then $a^2=λ^2=3\frac{λ^2}{3}$.
When $λ^2$ is divided by 3 there are three possible remainders $0,1,2$. So 
$$ λ^2=3k \lor λ^2=3k+1 \lor λ^2=3k+2   $$


*

*$ λ^2=3k \rightarrow a^2=3\frac{3k}{3}=3k $

*$ λ^2=3k+1 \rightarrow a^2=3\frac{3k+1}{3}=3k+1 $

*$ λ^2=3k+2 \rightarrow a^2=3\frac{3k+2}{3}=3k+2=3μ, μ\in \mathbb{Z} $


Therefore $$a^2=
 \begin{cases} 
      3k \\
      3k+1
   \end{cases}
$$
where $k$ is an integer.
Can someone verify this? Any help will be appreciated. Thanks in advance!

By the division algorithm
\begin{equation}
x=3q+r, \quad r \in \{0, 1, 2\}
\end{equation}
writing
\begin{align}
x^{2} &= 9q^{2}+r^{2} +6qr \\
&= 3(3q^{2}+2qr)+r^{2}
\end{align}
The result follows if for a given $x$, $r=0, 1$. If $r=2$ then clearly $r^{2}=4=1+3$ and thus
\begin{align}
x^{2} &=3 \lambda + 1 + 3 \\
&= 3(\lambda + 1) +1
\end{align}
(I should make it clear that it is obvious why $\lambda$ is an integer)
Q.E.D
