# What is the formula for generating an increasing sequence of odd numbers in which each number appears two consecutive times?

I want to come up with a closed formula for generating the sequence: $$\{1,1,3,3,5,5,7,7,9,9,11,11,...\}$$

It is possible to generate the odd numbers by $$a_n = 2n+1$$

The problem is to make every term repeat itself once sequentially. The sequence $$a_n = 2n+(-1)^n$$ generates $\{1,1,5,5,9,9,11,11,\dots\}$.

I can't think of a solution. Is there any?

• The sequence $1,2,3,4,5,\dots$ gets every other number right. Can you think of a way to add something to the (very simple) formula that generates $1,2,3,4,5\cdots$ that corrects the even numbers to match your sequence? Oct 31 '17 at 16:02
• Your average increase is just $1$ so you don't want to multiply $n$ by $2$. What goes wrong with $n+(-1)^n$ as an attempt to correct things, and how can you adjust that to make it work. Oct 31 '17 at 16:10
• There are several correct answers to your question. Any of them will be harder for your reader to parse and understand than just seeing the start of the sequence as you have written it. I suggest you just write that. Oct 31 '17 at 16:28
• $$a_n=\frac{1}{2} (-1)^n \left((-1)^n (2 n+1)+1\right)$$ Oct 31 '17 at 18:02
• Your title seems inconsistent with your sequence, as $1$ occurs only once ... Nov 1 '17 at 2:17

try this $a_n=\frac{2n+1+(-1)^n}{2}$

We want a function $f$ that gives $f(n)=n$ if $n$ is odd and $f(n)=n+1$ if $n$ is even.

We can let $f(n)=n+g(n)$ where $g$ is a function such that $g(n)=0$ if $n$ is odd and $g(n)=1$ if $n$ is even. We can take a modification of cos to get $g(x)=\cos^2(\frac{\pi x}{2})$.

So we get $f(x)=x+ \cos^2(\frac{\pi x}{2})$

Another posibility for $g(x)$ is $\frac{1}{2} + \frac{(-1)^n}{2}$

• I likek the way you've put a thought process in the deduction of the formula. Will help when trying to deduce other progression formulae. Nov 1 '17 at 11:25

If you prefer using the floor function, then $$2\left\lfloor\dfrac{n+1}{2}\right\rfloor+1, n\geq0.$$