How to reverse formula $S = \frac{n(n+1)}{2}$

911 Views Asked by At

I'm using this formula $S = \frac{n(n+1)}{2}$ to calculate sum of numbers from 1 to $n$.

But, I want to recover $n$ value. If I have $S$ value. Is it possible?

If yes, please provide that formula. Thanks.

1

There are 1 best solutions below

4
On BEST ANSWER

If we reorder the relation we have,

$2s=n^2+n \Rightarrow n^2+n-2s=0 $

which is just a quadratic equation in n, the roots of which by the quadratic formula are given by

$n=\frac{-1\pm\sqrt{8s+1}}{2}$

However $n \in \Bbb{Z}^+$ so we are only concerned with

$n=\frac{-1+\sqrt{8s+1}}{2}$

which completes your answer.