Formula for the $n$th term of $1, 2, 2, 3, 3, 3, 4, 4 ,4, 4, 5, ...$

I don't think there is a better formula, as it is based on two basic observations:

  • $\displaystyle \sum_{k=0}^{m-1}k=\frac{m(m-1)}{2}$.

  • $\displaystyle \frac{m(m-1)}{2}=n$ with $m>0$ $\Longrightarrow$ $\displaystyle m=\frac{1+\sqrt{1+8n}}{2}$.


Further explanations:

We have a sequence $\{a_n\}$ such that $a_0=1$, $a_1=a_2=2$, $a_3=a_4=a_5=3$, etc, and we want to have a general formula for $a_n$.

To obtain it, let us first ask a somewhat inverse question: for which $n$'s $a_n$ will be equal to a given number $m$? Here we will use the first formula: the numbers from $1$ to $m-1$ occupy $1+2+3+\ldots+(m-1)=m(m-1)/2$ first positions in the sequence. Therefore the number $m$ will correspond to $m$ values of $n$ explicitly given by $$n=\frac{m(m-1)}{2}+1,\frac{m(m-1)}{2}+2,\ldots,\frac{m(m-1)}{2}+m\tag{1}$$ Now we come back to our initial question. Given $n$, (1) implies that $a_n$ will be equal to the largest integer $m$ such that $\displaystyle \frac{m(m-1)}{2}\leq n$. This largest integer is obtained by solving the equation $\displaystyle\frac{m(m-1)}{2}= n$ for $m$ (here we use the 2nd formula) and taking the integer part of the solution.


There is a better formula: $$a_n = \operatorname{round}{\sqrt {2n}} $$

Where $\operatorname{round}$ means to round to the nearest integer, or if you prefer, $\operatorname{round}{x} = \left\lfloor x+\frac12\right\rfloor$