Find all even numbers that can be represented as a difference of squares in only two ways

Outline: As you know, we are solving $(a-b)(a+b)=n$, with the side requirement that $a+b$ (and therefore $a-b$), are even.

So $n$ is of the shape $4m$. If $st=m$, we get the solution $a-b=2s$, $a+b=2t$. Thus the number of representations is the number of ways to express $m$ as a product $st$ with $0\lt s\le t$.

Now there is some work for you to do. What numbers $m$ can be expressed in precisely two ways as $st$, where $0\lt s\le t$?


My claim is that all numbers $x$ for which $x=8k+16$ will have exactly two representations.

Counterexample: \begin{align} 120 &= 31^2-29^2 \\ &= 17^2 - 13^2 \\ &= 13^2-7^2 \\ &= 11^2-1^2 \end{align}


Note that while I just picked a number divisible by $8$ with plenty of factors, the claim actually falls at $48$: \begin{align} 48 &= 13^2-11^2 \tag{from (12,1)}\\ &= 8^2 - 4^2 \tag{from (6,2)}\\ &= 7^2-1^2 \tag{from (4,3)}\\ \end{align} because $48/4=12$ has three pairs of factors.


We have $$2n=a^2-b^2=(a-b)(a+b)$$ $a-b$, $a+b$ must be of the same parity, and that parity must be even, since otherwise their product wouldn't be the even number $2n$. Hence $n$ is even, so we may as well have $$4m=(a-b)(a+b)$$ or $$m=\frac{a-b}{2}\frac{a+b}{2}$$

Hence, we factor $m=st$, with $s\le t$, and set $\frac{a-b}{2}=s$, $\frac{a+b}{2}=t$, or $a=s+t$, $b=t-s$.

For $16$, we have $4=1\cdot 4=2\cdot 2$. This leads to $\{a=5, b=3\}$ and $\{a=4,b=0\}$.

For $24$, we have $6=1\cdot 6=2\cdot 3$.

For $32$, we have $8=1\cdot 8=2\cdot 4$.

It appears that the desired $n$ are of the form $4pq$, for $p,q$ not necessarily distinct primes, and of the form $4p^3$. $pq$ has factorizations $1\cdot pq=p\cdot q$, and $p^3$ has factorizations $1\cdot p^3=p\cdot p^2$. It's a bit tedious to look at various cases, but I'm fairly sure that all other forms for $n$ will have more than two factorizations, leading to more than two $\{a,b\}$ pairs. Also not proved (but I think not too hard) is that two different factorizations must lead to different $\{a,b\}$ pairs.