Velvet Star Monitor

Standout celebrity highlights with iconic style.

updates

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

Writer Emily Wong
$\begingroup$

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.

$\endgroup$ 7

1 Answer

$\begingroup$

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.

$\endgroup$ 4