## Quadratic Differences

#### Problem

The positive integers, $x$, $y$, and $z$ are consecutive terms in an arithmetic progression. Given that $n$ is also a positive integer, for how many values of $n$ below one-thousand does the equation $x^2 - y^2 - z^2 = n$ have no solutions?

#### Solution

Let $x = a + d$, $y = a$, and $z = a - d$.

$\therefore (a + d)^2 - a^2 - (a - d)^2 = n$

$a^2 + 2ad + d^2 - a^2 - a^2 + 2ad - d^2 = n$

$\therefore 4ad - a^2 = a(4d - a) = n$.

Let $u = a$ and $v = 4d - a \implies u + v = 4d \equiv 0 \mod 4$. In other words, for a solution to exist the factors of $n$ must add to a multiple of four.

We shall deal with $n$ being of the form $2^m r$, where $r$ is odd, and for increasing values of $m$.

$m = 0$ ($n$ is odd):

If $n = r$ then the factors $u$ and $v$ must both be odd. But if they are both congruent with 1 or both congruent with -1 modulo 4 then $u + v \equiv 2 \mod 4$, and there will be no solution; if they are different then $u + v \equiv 0 mod 4$, and there will always be a solution.

Hence if they are the same then $n = uv \equiv 1 \mod 4$, or $n$ being of the form 4$k$ + 1, will have no solutions.$m = 1 \implies n = 2r = a(4d - a)$:

If $a = 2r$, $4d - a = 1 \implies 4d = 2r + 1$. But as the RHS is odd, this is impossible.

If $a = r$, $4d - a = 2 \implies 4d = r + 2$. Impossible, as RHS is odd.

In other words if $n = 2(2k + 1) = 4k + 2$ then there will be no solutions.$m = 2 \implies n = 4r$:

If $a = 2r$, $4d - a = 2 \implies 4d = 2r + 2 = 2(r + 1)$.

And as $r + 1$ is even, we will always have at least one solution if $n = 4r$.$m = 3 \implies n = 8r$:

If $a = 8r$, $4d - a = 1 \implies 4d = 8r + 1$. Impossible.

If $a = 4r$, $4d - a = 2 \implies 4d = 4r + 2$. Impossible.

If $a = 2r$, $4d - a = 4 \implies 4d = 2r + 4$. Impossible.

If $a = r$, $4d - a = 8 \implies 4d = r + 8$. Impossible.

Hence if $n = 8(2k + 1) = 16k + 8$ then there will be no solutions.$m \ge 4$:

If $a = 4r$, $4d - a = 2^{m-2} \implies 4d = 4(r+2^{m-4})$.

Hence for $m \ge 4$ there will always be at least one solution.

Thus there will be no solutions for numbers of the form $4k + 1$, $4k + 2$, and $16k + 8$. As the first and second cases are odd and even respectively, they are mutually exclusive, and although the the second and third are both even, the third is divisible by 4, whereas the second is not divisible by 4. Hence all three forms are mutually exclusive.

As $4 \times 249 + 1 = 997$, $4 \times 249 + 2 = 998$, and $16 \times 61 + 8 = 984$, there are exactly $249 + 249 + 61 = 559$ values of $n$ below one-thousand that have no solution.

For which values of $n$ will there be exactly one solution?