# What number comes next in this sequence?

What comes next in this sequence?

4, 3, 9, 5, 19, 9, 39, 17, 79, 33, ?

It didn't immediately jump out at me, but ended up not too challenging and thought some may enjoy it.

It is:

4, 3, 9, 5, 19, 9, 39, 17, 79, 33, 159, 65, 319, 129

Because:

The differences between every other number are:
5, 2, 10, 4, 20, 8, 40, 16

So the odd entries begin with $4$ and add $5\times2^n$ to each.
The even entries begin with $3$ and add $2^n$ to each.

In appropriate math notation, thanks to f'':

$2x\,\text{th}$ term is $2^x+1$ and the $2x+1\,\text{th}$ term is $5⋅2^x−1$.

• The closed form is that the $2x$th term is $2^x+1$ and the $2x+1$th term is $5\cdot2^x-1$. – f'' May 10 '16 at 2:21
• Ah, ninja'd. This tablet types angle brackets too slowly :) – paste May 10 '16 at 2:24

The next numbers in sequence are

159, 65, 319, ...

The formula of the sequence is:

$(2^{\frac{n}{2}}) \cdot (2^{\frac{3}{2}}+2^{-\frac{1}{2}})^{nmod2}+(-1)^{n}$, where $n$ is the nth term and $nmod2$ is n modulo 2

The formula is deduced using the following logic:

To get the odd terms (where n = 1, 3, 5, ...), the following formula is used:

$2^{(\frac{n+1}{2}+1)} + 2^{(\frac{n+1}{2}-1)} - 1$
$=(2^{\frac{n}{2}})(2^{\frac{3}{2}}+2^{-\frac{1}{2}}) - 1$

To get the even terms (where n = 2, 4, 6, ...). the following formula is used:

$2^{\frac{n}{2}}+1$

There are only two differences in the above two formulas, one is $(2^{\frac{3}{2}}+2^{-\frac{1}{2}})$ and the other is the last constant $1$. To combine those two formulas, these two differences need to be addressed

1. As can be deduced from the above two formulas, $(2^{\frac{3}{2}}+2^{-\frac{1}{2}})$ is needed to obtain the odd terms while it is not needed to obtain the even terms. Hence a power of $nmod2$ is added so that $(2^{\frac{3}{2}}+2^{-\frac{1}{2}})^{nmod2} = 1$ when $n$ is even

2. As for the last constant, using $(-1)^n$ should suffice

After combination, the final formula is obtained: $(2^{\frac{n}{2}}) \cdot (2^{\frac{3}{2}}+2^{-\frac{1}{2}})^{nmod2}+(-1)^{n}$

I hope that my logic of deduction is easy enough to understand. Do comment on unclear parts =)