Q:

$n$th element of sequence $1223334444\ldots$ where $M$ occurs $M$ times

How do find the $n$'th element of this sequence 
$$122333444455555666666\ldots$$
Here the integer $M$ occurs $M$ times. Say if $M$ is given as $6$ then we don't move ahead of what I have written else if $M$ is $7$ we keep adding $7$ seven times and so on.
The solution in the book is 
Floor of (√2n+1/2) .But couldn't get how ?

A:

Hint: if you denote the $k$th term as $T_k$, then:
Terms $T_{\frac 12 (n)(n-1) + 1}$ to $T_{\frac 12 (n)(n+1)}$ inclusive will be all $n$.
Those subscripts are related to triangular numbers.

