# Deriving a formula for an arbitrary term in $1, 2, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, \ldots$

A sequence of numbers is given as: $$1, 2, 2, 3, 3, 3, 4, 4, 4, 4, \text{and so on}$$ (Each integer $$n$$ is repeated $$n$$ times.) What will be the 50th term of that sequence?

Let's say $$x=50$$. Then solving $$x=n(n+1)/2$$ gives the value of $$n$$ (rounded off to nearest integer).

My question is: If I make a small change in the above pattern, can we have a direct formula to calculate $$n$$?

The new pattern is : $$1, 2, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, \ldots$$ i.e., $$1$$ and $$2$$ are repeated once, and $$n$$ is repeated $$(n-1)$$ times.

How can we derive a formula for this pattern?

• You can ignore the existence of the $1$, and then notice that the sequence $2,3,3,4,4,4,5,5,5,5,\dots$ is simply the sequence where each entry is one more than the corresponding entry in the earlier mentioned sequence. – JMoravitz Jan 30 at 19:25
• Yeah i get that, but let's say i'm only provided with 'x' and i need to find the corresponding 'n' for it according to the new sequence – Maxy Daen Jan 30 at 19:31

Using JMoravitz hint above, you can replace $$x$$ with $$x-1$$ and $$n$$ with $$n-1$$ and now your formula is $$x-1=(n-1)(n)/2$$. Whatever you get for n should be rounded up to the nearest integer if it isn't an integer already.
For example for $$x=5$$, we have $$4 = (n-1)(n)/2 \to 8 = (n-1)(n) \to n^2-n-8=0 \to n=3.37$$ which rounds up to 4.
• Ultimately this amounts to the formula $$n = \left \lceil \frac 12 (\sqrt{8x - 7} + 1) \right \rceil$$ – Omnomnomnom Jan 30 at 19:59