Get N value of this pattern (Triangular Number)

418 Views Asked by At

I have numbers formatted into this pattern. $$ 1,2,2,3,3,3,4,4,4,4,5,5,5,5,5,6,6,6,6,6,6,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,11,\dotsc $$ What I need is getting number value in $n$. for example $n = 13$, so the answer is $5$. What is the formula?

1

There are 1 best solutions below

2
On BEST ANSWER

We take advantage of your list. Note that there are $1+2+3+\cdots +9$ numbers until the end of the $9$'s. The sum $1+2+3+\cdots+9$ is an arithmetic sequence, with sum $\frac{(9)(10)}{2}$.

More generally, the number of numbers until the end of the $n$'s is $\frac{n(n+1)}{2}$.

The approximate size of the $N$-th number in our list is the $n$ such that $\frac{n(n+1)}{2}=N$. Of course there will not necessarily be an $n$ such that $\frac{n(n+1)}{2}=N$. But let us find the smallest $n$ such that $\frac{n(n+1)}{2}\ge N$. So we want to find $n$ such that $$\frac{n(n+1)}{2}\le N\lt \frac{(n+1)(n+2)}{2}.\tag{1}$$ Now do a bit of manipulation. Multiply through by $8$. Our inequality (1) is equivalent to $$4n^2+4n \le 8N\lt 4n^2+12n+8.$$ Completing the squares, we get $$(2n+1)^2 \le 8N+1\lt (2n+3)^2.\tag{2}$$

This gives us our recipe (formula). Take the smallest odd number $q$ which is $\ge \sqrt{8N+1}$. Then $n=\frac{q-1}{2}$.

Example: Let $N=13$. Then $8N+1=105$. The square root of this is a bit bigger than $10$. The smallest odd $q$ bigger than this is $11$. and $\frac{11-1}{2}=5$.