If $n$ is an odd integer, then there exist integers $a$ and $b$ such that $n=a^2-b^2$. [duplicate]

Solution 1:

Trying to express $n=a^2-b^2$, we note that $a^2-b^2=(a+b)(a-b)$ and so we try the simplest solution $a+b=n$ and $a-b=1$. This leads to $a=(n+1)/2$ and $b=(n-1)/2$, which are indeed integers because $n$ is odd.

This approach also works for $n$ even, but we have to try the next simplest solution: $a+b=n/2$ and $a-b=2$. This leads to $n$ having to be a multiple of $4$ and $a=n/4+1$ and $b=n/4-1$.

This completely characterizes the numbers $n$ that can be expressed as the difference of two squares: $n$ is odd or $n$ is a multiple of $4$.

Solution 2:

Hint: $2k+1 = 1\cdot \left((k+1)+k\right)$.