# Proving expressibility of integers as the difference of two squares.

Prove that a positive integer is expressible as the difference of two squares of integers if and only if it is not of the form $4n+2, n\in\mathbb{Z}$

I was given a hint that I can just explicitly express $4n$, $4n+1$, and $4n+3$ as the difference of two squares to prove the $\rightarrow$ direction.

Probably a trivial question but how do I go about representing an integer of the form $k = 4n+1$ for $k, n \in \mathbb{Z}$ as the difference of two squares?

And why does this procedure satisfy the 'if'-portion of the proof?

• For example let $m$ be odd, and let $ab=m$ (we can take $a=1,b=m$). We want to solve $x^2-y^2=m$. Set $x-y=a$, $x+y=b$ and solve for $x$ and $y$. We get $x=\frac{b+a}{2}$, $y=\frac{b-a}{2}$. Since $a$ and $b$ are odd, $x$ and $y$ are integers. Apr 23 '15 at 6:36

Hint The difference of $(m + 1)^2$ and $m^2$ is $2 m + 1$.
The $\Leftarrow$ (if) direction just asserts that if an integer does not have the form $4 n + 2$ then it is expressible as a difference of squares. But any integer has the form $4 n$, $4 n + 1$, $4 n + 2$, or $4 n + 3$ for some $n$, so this direction is equivalent to showing that general integers of each of the other three forms is expressible as such a difference.
$(m+1)^2-m^2=2m+1$, so this covers $4k+1, 4k+3$.
$(m+2)^2-m^2=4(m+1)$, so this covers all numbers of the form $4k$.
$4n+2$ is impossible as $k^2$ is either $0$ or $1$ mod $4$, so we can only have $0-0, 1-0, 0-1, 1-1 (\equiv 0, 1, -1, 0) \mod 4$.