1

Given the following formula, in order to obtain a given $k$, you need to find the value of $n$.

$1 + 2 + 3 +\dots + n = k$

For example:

Given $k = 15$, The expression to be used will be: $1 + 2 + 3 + 4 + 5 = 15$

Here $n = 5$

Is there any formula to solve for $n$?

Smylic
  • 6,715

1 Answers1

4

This is a widely known formula for the triangular numbers:

$$k=1+2+3\dots+n$$

$$k=\frac{n(n+1)}{2}$$

So by inversing that to find $n$ we get:

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


Note that this result is obtained by solving the quadratic equation $0=n^2+n-2k$, hence we should have $\frac{1}{2}(-1\pm\sqrt{8k+1})$, but we can eliminate the second solution since you are looking strictly for solutions to the summation itself.

Vepir
  • 12,516