Find $1 \le a < b \le n$ such that $a\cdot b + a + b = n\cdot (n+1)/2$

68 Views Asked by At

Find $1 \le a < b \le n$ such that $$a\cdot b + a + b = \frac{n\cdot (n+1)}2$$

Is there a more efficient way than picking $a$ or $b$ and trying all values between $1$ and $n$ ?

1

There are 1 best solutions below

5
On

$(a+1)(b+1)=\dfrac{n^2+n+2}{2}$.

If $a$ and $b$ are restricted to integers, consider the factors of $\dfrac{n^2+n+2}{2}$.