triangle row count from total points $x = \frac{n(n + 1)}2$

47 Views Asked by At

I'm trying to find the row count for triangle inputting the total number of points.

I've found this, where $x$ is the total points, and $n$ is the rows. I'm having trouble solving it for $n$

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

$2x = n(n+1)$

$2\frac xn = n+1$

This is as far as I've got, any guidance would be appreciated.

Imgur

3

There are 3 best solutions below

3
On BEST ANSWER

If I understand you correctly, you’re given the number $\frac12n(n+1)$ and wish to calculate $n$ from it. Here are two approaches.

  1. Let $m$ be the number that you’re given; you want to solve $m=\frac12n(n+1)$ for $n$. This equation can be rewritten as $n^2+n-2m=0$, which can then be solved for $n$ with the quadratic formula: $$n=\frac{-1+\sqrt{1+8m}}2\;.$$ (I’ve ignored the negative root, since we clearly don’t want it.

  2. Alternatively, notice that $2m=n(n+1)$, so $n\approx\sqrt{2m}$. This square root always lies between $n$ and $n+1$, so $n=\lfloor\sqrt{2m}\rfloor$, where $\lfloor x\rfloor$ is the largest integer less than or equal to $x$.

0
On

Hint: Rearranging, we obtain: $$ n^2 + n - 2x = 0 $$

Now apply the quadratic formula (treating $n$ as the variable and $x$ as a constant).

0
On

You have $n^2+n=2x$ which is a quadratic equation. Multiply by 4 and add 1 ("completing the square") $$4n^2+4n+1=8x+1=(2n+1)^2$$

Take the square root $$2n+1=\sqrt {8x+1}$$

Rearrange to isolate $n$

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

(the negative square root would make $n$ negative)