How to check if a number can be represented as product of 2 consecutice numbers?

41 Views Asked by At

How to check if a number can be represented as product of 2 consecutice numbers?

Eg 56 can be represented since 56 = 7*8

72 can be represented since 72 = 8*9

1

There are 1 best solutions below

2
On BEST ANSWER

Suppose that the number you want to test is $N > 0$. Then, you are asking whether the following quadratic has a positive integer solution: $$x(x + 1) = N.$$

Note that the solutions of the above can be explicitly found as:

$$x = \dfrac{-1 \pm \sqrt{4N + 1}}{2}.$$

Now, it is clear that $4N + 1$ must be a perfect square. For otherwise, both the roots will be irrational. Now, the good thing to observe is that if $4N + 1$ is a perfect square, then its square root is odd. Thus, the number

$$\dfrac{\sqrt{4N + 1} - 1}{2}$$ is indeed an integer!

Thus, this concludes the discussion and gives you the necessary and sufficient condition: $$\sqrt{4N+1} \text{ must be a perfect square.}$$

(Moreover, you also have the way of finding the two consecutive integers using the above formula.)


EDIT: For three numbers: We could proceed in the same manner.
Set up the cubic $x(x+1)(x+2) = N$ and use the cubic formula to test if any of the three roots is a positive integer. The criteria, in this case, might not be as simple.

This can be extended for 4 integers as well using the same method. However, for 5 or more, we would run into a problem as we don't have a closed-form expression for the roots of a polynomial of degree 5 (or higher). (Note that it doesn't mean that we can't solve any degree 5 polynomial. Maybe you still could exploit some symmetry and do it.)