Suppose we have sequence given by
$$ (1,2,2,3,3,3,4,4,4,4,5,5,5,5,5,...) $$
I need to prove that $a_n = \lfloor{ \sqrt{2n} + \frac{1}{2} \rfloor} $.
Try:
I notice the following. The last occurrence of 1 occurs at $a_1$, the last occurrence of $2$ occurs at $a_3$, the last occurrence of $3$ occurs at $a_6$. So, if we define $F(n)$ to be the last occurrence of digit $n$, then we guess
$$ P(n) = \frac{n(n+1)}{2} $$
Who show by induction. base case is clear. Suppose the formula holds true for some $k$, that is suppose $P(k) = \frac{ k(k+1) }{2}$.
Note $P(k+1) = P(k) + k+1$
since the (k+1)th last entry is k+1 positions after the kth entry. Thus,
$$ P(k+1) = \frac{k(k+1)}{2} + k+1 = \frac{(k+1)(k+2)}{2} $$
and guess is true by induction.
Now, let $a_n = m$. Since $a_n$ must lie between $P(m-1)$ and $P(m)$ we have
$$ P(m-1) < n \leq P(m) \implies \frac{ (m-1)m}{2} < n \leq \frac{m(m+1)}{2} \implies m^2 - m < 2n \leq m^2 + m $$
now, since $m^2 + m + 1/4 > m^2 + m$ and since adding $1/4$ to $m^2-m$ would still be less than $2n$, then
$$ m^2 - m + \frac{1}{4} < 2n < m^2 +m + \frac{1}{4} \iff (m-1/2)^2 <2n < (m+1/2)^2 $$
Thus,
$$ m - 1/2 < \sqrt{2n} < m + 1/2 \implies m < \sqrt{2n} < m + 1$$
Hence, $m = a_n = \lfloor{ \sqrt{2n} + \frac{1}{2} \rfloor}$.
Is this a correct argument? Any feedback would be really appreciated. IS there a better approach to solve this problem?