# Finding the “triangular root” of a number.

A triangular number is a number that is the sum of the natural numbers up to some $n$. The closed form is $x = \frac{n(n+1)}{2}$. How do I get $n$ on one side? I've been looking at it from every angle, and I can't find out how. Any help?

-
Do you know the quadratic formula? – Tobias Kildetoft Mar 4 '14 at 14:44

The answer elsewhere in this thread is of course correct, but for actual calculation there is a simpler answer. We have $x = \frac12(n^2 +n)$ where $x$ is known and we want to find $n$. This is equivalent to $$2x+\frac14 = \left(n+\frac12\right)^2$$ or, neglecting the fractions, which I could justify with a more careful analysis, but won't, $$n\approx \sqrt{2x}.$$

And indeed the formula $$n = \left\lfloor\sqrt{2x}\right\rfloor$$ always gives the correct answer. ($\lfloor\ldots\rfloor$ just means to drop the fraction.)

-
You might want to prove that it always gives the correct answer. Nice trick though :) – Sawarnik Mar 4 '14 at 19:42
I thought it might be more fun if I left it as an exercise. – MJD Mar 5 '14 at 2:23
You might want to check the answer by substituting it back in the original formula though, since this is going to give an integer always. Nice trick +1. :) – Sabyasachi Mar 5 '14 at 9:26

$$n^2+n=2x$$

$$n^2 +n - 2x = 0$$

$$n = \frac{-1 +\sqrt{1+8x}}{2}\text{ provided n \in \mathbb N, otherwise undefined}$$

For anyone unfamiliar, see proof.

-
Ah, how did I forget about the quadratic formula? Thanks for the help! – undo_all Mar 4 '14 at 14:47
You're very welcome. :) – Sabyasachi Mar 4 '14 at 14:48
This also proves that $1+8x$ must be a perfect square. – Sawarnik Mar 4 '14 at 19:27
@Sawarnik yes, that condition is necessary and sufficient, since for all integers $x$, $1+8x$ is odd, and therefore, $\sqrt{1+8x}$ is odd and thus, $n \in \mathbb Z$ – Sabyasachi Mar 5 '14 at 9:21