# Function that produces sequence 112123123412345…

I'm trying to find a function/formula for $a_n$ such that it produces the sequence $112123123412345$ and so on.
I know that one possible way to do this is to find a function like $n-b_n$ where $b_n$ is a function that produces the sequence $0,1,1,3,3,3,6,6,6,6,10,10,10,10,10..$.
I know that the function $\lfloor{\sqrt{n}}\rfloor^2$ produces a somewhat similar sequence to $b_n$ in that it as a series of increasingly large sets of repeated numbers.
However, I am a bit lost on how to proceed from here.
What I am trying to achieve is a sequence such that, for any natural number, there exists a subsequence with that natural number as it's limit. I need to do this without using the $floor$ function. Otherwise, an example of a solution would be $n-\lfloor{\sqrt{n}}\rfloor^2$.

• When you get to the portion of the sequence that you would write $...678910111213...$, do the commas that usually separate terms go between numbers or digits? I.e., did I just write down eight terms of the sequence or twelve? – Barry Cipra Mar 7 '16 at 14:42
• If I were to go that far, I would have to put down commas between each term of sequence to keep it consistent. I agree that writing it the way I did is lazy and can be confusing. – jessicajjensen Mar 9 '16 at 23:01

We have $a_{\frac{1}{2}N\left(N-1\right)+k}=k$ for $1\leq k\leq N$. If $f\left(x\right)$ is the non-negative inverse of $\frac{1}{2}x\left(x-1\right)$, then $$a_n=n-\frac{1}{2}\lfloor f\left(n-1\right)\rfloor\left(\lfloor f\left(n-1\right)\rfloor-1\right).$$ In fact $f=\frac{\sqrt{8x+1}+1}{2}$, so $$a_n=n-\frac{1}{2}\bigg\lfloor \frac{\sqrt{8n-7}+1}{2}\bigg\rfloor\bigg\lfloor \frac{\sqrt{8n-7}-1}{2}\bigg\rfloor.$$

• Thank you. Is there any way to achieve this result without utilising the $floor$ function? – jessicajjensen Mar 6 '16 at 21:10
• @jessicajjensen no there isn't if you want to use this method. – Stella Biderman Mar 6 '16 at 21:20
• Alright, this gives me the correct answer and I will mark it as such if I don't get another answer that somehow achieves this result without the floor function. – jessicajjensen Mar 6 '16 at 21:22
• The identity $\lfloor x\rfloor=x-\left\{ x\right\}$ can be used, but that may not be in the spirit of this constraint. – J.G. Mar 6 '16 at 22:05
• Alright, thanks a lot! – jessicajjensen Mar 7 '16 at 14:14