Which positive integers $a$ and $b$ make $(ab)^2-4(a+b) $ a square of an integer? Which positive integers
$a$ and $b$ make
$(ab)^2-4(a+b)
$
a square of an integer?
I saw this in quora,
and found that
the only solutions with
$a \ge b > 0$
are
$(a, b, (ab)^2–4(a+b)) = (5, 1, 1)$
and $(3, 2, 16)$.
Another “solution” is
$a = b = 2, (ab)^2–4(a+b) = 0$.
My solution is
messy and computational,
and I wonder if
there is a more elegant solution.
Here is my solution.
Assume $a \ge b$
and write
$n^2 = (ab)^2–4(a+b)$ so $n < ab$.
Let $n = ab-k$
where $ab > k>0$ so
$(ab)^2–4(a+b) = (ab-k)^2 = (ab)^2–2kab+k^2$
or
$k^2–2kab+4(a+b) = 0$.
Then
$\begin{array}\\
k 
&= \dfrac{2ab-\sqrt{4a^2b^2–16(a+b)}}{2}
\qquad \text{(use "-" since } k < ab)\\
&= ab-\sqrt{a^2b^2–4(a+b)}\\
&=(ab-\sqrt{a^2b^2–4(a+b)})\dfrac{ab+\sqrt{a^2b^2–4(a+b)}}{ab+\sqrt{a^2b^2–4(a+b)}}\\
&=\dfrac{4(a+b)}{ab+\sqrt{a^2b^2–4(a+b)}}\\
\end{array}
$
Therefore,
since $k \ge 1, 4(a+b) \ge ab$
so
$0 \ge ab-4(a+b) = ab-4(a+b)+16–16
 =(a-4)(b-4)-16$
or $16 \ge (a-4)(b-4)$.
This gives a finite number of possible $a, b$,
all at least $4$.
Computation shows that
none of these are solutions.
To get the possible values of
$a$ and $n$ in terms of $b$
for any fixed $b$,
do this:
Since
$n^2
= a^2b^2-4(a+b)$,
$\begin{array}\\
b^2n^2 
&= a^2b^4-4b^2a-4b^3\\
&= a^2b^4-4b^2a+4-4b^3–4\\
&=(b^2a-2)^2–4(b^3+1)\\
\end{array}
$
so
$4(b^3+1) 
= (b^2a-2)^2-b^2n^2 
= (b^2a-2-bn)(b^2a+bn)
$.
For each factorization
$r*s = 4(b^3+1)$, try
$r=b^2a-2-bn, s=b^2a-2+bn$.
This gives
$s-r=2bn$,
so if $2b$ divides $s-r$,
then
$n=\dfrac{s-r}{2b}$.
Adding $s$ and $r$,
$2b^2a-4=s+r$ so if
$2b^2$ divides $s+r+4$,
then $a = \dfrac{s+r+4}{2b^2}$.
This allows us to compute all solutions for any fixed value of b.
Running this for $1 \le b \le 16$
gives the solutions above.
For $a \ge b \ge 5$,
the restriction
$16 \ge= (a-4)(b-4)$
gives a finite set of possibilities which computation shows yields no additional solutions.
I sure would like to see
a more elegant solution.
Also,
this messy algebra
provides lots of opportunities
for errors.
 A: We can find an upper bound for their "product" in the following way:
\begin{align}
{\left( {ab} \right)^2} - 4\left( {a + b} \right) &< {\left( {ab} \right)^2} \ \  (\because a,b>0) \\
 {\left( {ab} \right)^2} - 4\left( {a + b} \right) &\le {\left( {ab - 1} \right)^2} \\
(2ab-1)-4(a+b) &\le 0\\
ab - 2(a+b) - \frac 12 \color{blue}{+4} &\le 0 \color{blue}{+4}\\
 \left( {a - 2} \right)\left( {b - 2} \right) &\le \frac{9}{2} \\
 \left( {a - 2} \right)\left( {b - 2} \right) &\le 4 \\
\end{align}
Now, seeing some cases should finish the work.
A: If $(ab)^2-4(a+b)$ is greater than $(ab-1)^2$ then it cannot be a square, since it is strictly between two consecutive squares. Hence
$$(ab)^2-4(a+b) \le (ab-1)^2=(ab)^2-2ab+1$$
$$2ab-4a-4b-1\le0$$
$$2(a-2)(b-2)=2ab-4a-4b+8\le 9$$
which, again, gives a finite set of possibilities to be checked.
WLOG suppose $a \ge b$. We need only consider the cases:

*

*$b=1,2$

*$b=3, a\le6$

*$b\ge 4, a < 3$ (this case contradicts $a\ge b$)

For $b=1$, $(ab)^2-4(a+b) = a^2-4a-4$. For $a\ge7$, $a^2-4a-4> a^2-6a+9=(a-3)^2$. But $a^2 -4a-4 < a^2-4a+4=(a+2)^2$. So we only need to check $1 \le a \le 6$.
For $b=2$, $(ab)^2-4(a+b) = 4a^2-4a-8$, which is a square only if $a^2-a-2$ is. For $a\ge4$, $a^2-a-2> a^2-2a+1 =(a-1)^2$. But $a^2-a-2<a^2$, so we only need to check $a=2,3$.
For $b=3$, $(ab)^2-4(a+b) = 9a^2-4a-12$, and we only need to check $3 \le a \le 6$.
