I have to show that $n=a^2-b^2$ iff $n\not\equiv 2$ (mod $4$). Where $a$, $b$ are integers.
I already got the explicit $(a,b)$ if $n\not\equiv 2$ (mod $4$). However, I am stuck with the other direction.
I know that $n=a^2-b^2=(a+b)(a-b)$. Now, I think that I have to show, that these factors have to have the same parity, so $n$ cannot be $2$ (mod $4$). Is this approach right?
Edit: I think it is also no restriction to just assume that $n$ is even. If $n$ is odd it already cannot be $2$ mod $4$
If $n$ is even then each of $a^2$ and $b^2$ must be either both odd or both even
ODD : Let $a=2m+1\ ;\ b=2n+1$ $$a^2-b^2=(2m+1)^2-(2n+1)^2=(2(m+n+1))(2(m-n))=4(m+n+1)(m-n)$$
EVEN :Let $a=2m\ ;\ b=2n$ $$a^2-b^2=4m^2-4n^2=4(m^2-n^2)$$
So in both cases you get $n$ as a multiple of $4$
Since you have already solved the $n=odd$ case You are done I think!