There is a sequence
$$X = {1,1,1,1,1,1,1 \dots 2,2,2,2,2,2,2,2 \dots,3,3,3,3,3,3 \dots 4,4,4,4,4,4,4 \dots (k-1),(k-1),k}$$
So there are $(k)$ 1's, $(k-1)$ 2's and $(k-2)$ 3's and so on. Is there a formula that can tell me what the $x[n]$th number is and if so how did you get that formula?
I know the sequence is $k(k+1)/2$ long.
It is easier to start counting from the end. There are $\frac 12k(k+1)=T_k,$ the $k^{th}$ triangular number. If you want the $n^{th}$ number, it is $T_k-n+1=p$ from the back. If $T_m \le p \lt T_{m+1}$, the number in question is $m$ We need to invert the calculaton of the triangular number. $T_m=\frac 12m(m+1)$ gives $m=\frac 12(-1+\sqrt{1+8T_m}),$ so the $n^{th}$ number is $k+1-\lfloor \frac 12(-1+\sqrt {1+8(T_k-n+1)}\rfloor$ Where the $k+1-$ comes because we are counting down.