I am solving a problem to Express a number as the sum of consecutive numbers.
So I figured out if we get the roots of quadratic equation form with the formula n((n+1)//2)
, we can do it o(1)
time complexity.
Suppose if we have any number x, if the quadratic equation formed using above formula n((n+1)//2) and the number x contains any valid roots, then it can be as the sum of consecutive numbers else not.