# Closed form solution to $\{a_n\}_{n=1}^{\infty} = 1,2,2,3,3,3,…$

I had thought about this sequence (where each positive integer $n$ shows up $n$ times) the other day and think I have a closed form solution. First of all we know that the last time that $k$ shows up in the sequence is at $a_{\frac{k(k+1)}{2}}$. We want to see if $a_n$ is one of these last occurrences. So we solve $$\frac{k(k+1)}{2} = n$$ for $k$. If $k$ is an integer then we know $a_n = k$ but if $k$ is not an integer then $a_n$ must be $\left \lceil k \right \rceil$ since the last occurrence of $\left \lfloor k \right \rfloor$ occurred before $n$. Therefore the value of $a_n$ is: $$\left \lceil \frac{\sqrt{8n+1} -1}{2}\right \rceil$$ Is this correct? Is there anything interesting about this sequence other that that the sum of it values and the sum of its reciprocals both diverge? Thanks.

-
Looks pretty solid. – alex.jordan Nov 29 '12 at 5:03
The feature that you mention that this sequence has is also shared by the more simple $\{1,2,3,\ldots\}$. – alex.jordan Nov 29 '12 at 5:04
It can also be defined recursively by $$a_1=1,\quad a_n=1+a_{n-a_{n-1}}$$ – Spenser Nov 29 '12 at 5:28

## 1 Answer

Your reasoning and result looks good. For more details and interesting properties on this sequence, have a look at the OEIS database. Note, that they also give the closed form expression assuming $n \ge 0$ (as against your $n \ge 1$) as follows:

$$\left \lfloor \frac{\sqrt{8n+1} + 1}{2}\right \rfloor, n\ge 0$$

For your definition ($n$ starts from 1), they also provide another closed for expression as:

$$\left \lfloor \frac{1}{2} + \sqrt{2n}\right \rfloor$$

You can look up the database for other properties and references for this sequence.

-
Thanks for introducing me to OEIS! Looks awesome. – Patrick Nov 29 '12 at 13:15
No problem! My reaction was the same when someone introduced me to OEIS, so glad I could do the same :) – Paresh Nov 29 '12 at 14:18