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???

  • 16
    $\begingroup$ Hint: Quadratic formula $\endgroup$
    – lulu
    Mar 23, 2018 at 11:43
  • 1
    $\begingroup$ @lulu Oh....... $\endgroup$ Mar 23, 2018 at 11:45

2 Answers 2


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.

  • 1
    $\begingroup$ Note that $8x+1$, if a square, is always going to be odd, so specifying that isn't necessary. $\endgroup$
    – user304329
    Mar 23, 2018 at 11:59
  • $\begingroup$ So $n=\max(\frac{-1+\sqrt{8x+1}}{2}, \frac{-1-\sqrt{8x+1}}{2})$? $\endgroup$ Mar 23, 2018 at 12:00
  • $\begingroup$ Note that $8x+1$ will always be odd, so the only condition is that it is a square. $\endgroup$ Mar 23, 2018 at 12:00
  • $\begingroup$ @user5011: Well, yes, but it's simpler just to say $n=\frac{-1+\sqrt{8x+1}}2.$ $\endgroup$ Mar 23, 2018 at 12:01
  • $\begingroup$ Okay, got it now. Thanks a lot!$n = \frac{-1+\sqrt{8x+1}}{2}$. $\endgroup$ Mar 23, 2018 at 12:02

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.


Not the answer you're looking for? Browse other questions tagged .