Given $x$, find $n$ such that $1 + 2 + 3 + ... n = x$

124 Views Asked by At

Given a number $x$, how do we find a value $n$ such that $$ 1+2+3+...+n =x $$ This is how far I've gotten: $$ x=\frac{n(n+1)}{2} $$ $$ 2x = n(n+1) $$ What do I do from here???

2

There are 2 best solutions below

5
On BEST ANSWER

Then we will have $n^2+n-2x=0$

You can find solution for $n$ if and only if $x$ is a natural number and $\Delta=1^2-4\times 1 \times (-2x)=8x+1\ge0$, which is true for all nautral numbers $x$.

Then we will have $n=\frac{-1+\sqrt{8x+1}}{2}$ or $n=\frac{-1-\sqrt{8x+1}}{2}$, but we will only take the positive integer solution, eliminate any non-integer solution.

Note that $8x+1$ must be a perfect square number so that $n$ can be a positive integer.

0
On

You need to solve $$ n^2+n-2x =0$$

As you know this quadratic equation may or may not have integer solutions.

For example $ x=55$ results in $n=10$ but $x=50$ does not have a round solution.