$n=a^2-b^2$ iff $n \not\equiv 2(\mathrm{mod\ }4)$

178 Views Asked by At

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$

2

There are 2 best solutions below

0
On BEST ANSWER

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!

0
On

For every integer numbers $a$ and $b$, we have

Point: $a-b$ is even (odd) if and only if $a+b$ is even (odd) because $a+b=a-b+2b$.

So, there are two cases to consider;

($1$) Assuming $a-b=2n$ and $a+b=2m$ which leads to $(a-b)(a+b)=4mn\equiv 0$ (mod $4$).

($2$) Assuming $a-b=2n+1$ and $a+b=2m+1$ which leads to

$(a-b)(a+b)=2(2mn+m+n)+1=2k+1\equiv 1\ \text{or}\ 3$ (mod $4$).

As a result, it is impossible that $a^2-b^2\equiv 2$ (mod $4$)