Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|cite|improve this question
2 is relevant to your question. – user61527 Mar 4 '14 at 4:09
thanks, I will check it – Noval Agung Prayogo Mar 4 '14 at 4:11
up vote 2 down vote accepted

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$.

share|cite|improve this answer
thanks ! great explanation – Noval Agung Prayogo Mar 4 '14 at 4:42
You are welcome. By using the "greatest integer (floor) function" o alternately the ceiling function, we can produce a more explicit "formula." You may want to work out such an expression. I did not do it because I think it subtracts from the idea. – André Nicolas Mar 4 '14 at 4:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.