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

3.2k Views Asked by At

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?

3

There are 3 best solutions below

1
On BEST ANSWER

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}$

0
On

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

0
On

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