Solution

Differences of Squares

Show the problem again

How many integers $n$ with $1 \le n \le 1000$ can be written as $n = a^2 - b^2$ for some nonnegative integers $a$ and $b$? Give an integer.

Worked solution

The answer is 750. Write $n = (a - b)(a + b)$; the two factors have the same parity. If $n$ is odd, take $a - b = 1$, $a + b = n$. If $4 \mid n$, take $a - b = 2$, $a + b = n/2$. So every odd number and every multiple of 4 works. If $n \equiv 2 \pmod 4$, two same-parity factors would be both odd (product odd) or both even (product divisible by 4), so no representation exists. Squares are 0 or 1 mod 4, which confirms that differences are never 2 mod 4. Among 1 to 1000 exactly 250 numbers are $\equiv 2 \pmod 4$, leaving 750.

Source: Classic exercise in wide circulation; no traceable original source. Statement written for AxiomIQ.