For $ \frac{n(n-1)}{2}<i \leq \frac{ n(n+1)}{2} $, why is $\text{round}(\sqrt{2i})=n$ I was doing Problem 67 of Project Euler, which involves number triangle which has similar structure to Pascal's triangle (the nth row contains n numbers). While thinking of a way to represent the triangle as a single list, I realized that the number of elements in a triangle of height n was $1+2+3+...+n = n(n+1)/2$, which must mean that the last number of any row n must be the $(n(n+1)/2)^{th}$ number in the triangle. More generally, we have that for any index $i$ starting at 1, $\frac{n(n-1)}{2} &lt; i \leq  \frac{n(n+1)}{2}$ where $n$ is the row that contains the $i^{th}$ number of the triangle. From here, I figured that taking the square root of $2i$ and rounding it would give something close to $n$, and indeed rounding the square root of $2i$ results in the pattern $1,2,2,3,3,3,4,4,4,4,5,5,5,5,5$, etc. So far, I have not been able to prove this result to myself, so any help would be appreciated, thanks!
$$\frac{(n-1)^2}2&lt;\frac{n(n-1)}2&lt;\frac{n^2}2&lt;\frac{n(n+1)}2&lt;\frac{(n+1)^2}2$$

We also know that

$$\frac{n(n-1)}2&lt;i&lt;\frac{n(n+1)}2$$

On finding differences, we realise that $i$ will always be closer to $\frac{n^2}2$ than $\frac{(n-1)^2}2$ or $\frac{(n+1)^2}2$

Hence $i=round(\sqrt{2i})$
$$\frac{(n-1)^2}2&lt;\frac{n(n-1)}2&lt;\frac{n^2}2&lt;\frac{n(n+1)}2&lt;\frac{(n+1)^2}2$$

We also know that

$$\frac{n(n-1)}2&lt;i&lt;\frac{n(n+1)}2$$

On finding differences, we realise that $i$ will always be closer to $\frac{n^2}2$ than $\frac{(n-1)^2}2$ or $\frac{(n+1)^2}2$

Hence $i=round(\sqrt{2i})$