# What number follows up next? Part 2

I'm trying to figure out what number follows next in this sequence. Can you help me?

5, 21, 341, 5461, 1398101, 22369621

OEIS doesn't list this sequence. After analyzing the pattern, I come to the conclusion that (one) answer is

$5726623061$

Explanation:

First we translate the given numbers of the sequence into binary numbers: $$5_{(10)}=101_{(2)}\Longrightarrow 2 \text{ ones}$$ $$21_{(10)}=10101_{(2)}\Longrightarrow 3\text{ ones}$$ $$341_{(10)}=101010101_{(2)}\Longrightarrow 5 \text{ ones}$$ $$5461_{(10)}=1010101010101_{(2)}\Longrightarrow 7 \text{ones}$$ $$1398101_{(10)}=101010101010101010101_{(2)}\Longrightarrow 11\text{ ones}$$ $$22369621_{(10)}=1010101010101010101010101_{(2)}\Longrightarrow 13\text{ ones}$$ All these numbers are binary palindromes. The number of ones corresponds to the sequence of prime numbers. The next prime number is 17, so we need a binary palindrome with exactly $17$ ones. This number will be translated into the decimal system and the result represents the next element in the sequence. $101010101010101010101010101010101_{(2)}=5726623061_{(10)}$

EDIT (05/06/18): I submitted this sequence to OEIS and it has (finally) been approved now.

• +1, nice spot. to put it another way the sequence is partial sums of the geometric series 2^(2n+1) with prime numbers of elements. Mar 26 '18 at 5:06
• I'd write this as $(4^p - 1)/3$ for successive primes $p$. Mar 26 '18 at 9:13

There can be infinite different solutions for any sequence given finitely many members. So, this answer may not be the solution you are looking for. Still, here is my attempt.

The first sequence that sort of matched the shown sequence I came with was:

$$5, [5+16], [5+(5+16)*16], [5+(5+(5+16)*16)*16], ..., [5+(n_{i-1})*16], ...$$

which goes:

$$5, 21, 341, 5461, 87381, 1398101, 22369621$$

But there is an additional term at 5th index. So, I rewrote your original sequence in this form:

$$5, [5+16], [5+16+20*16], [5+16+20*16+20*16^2], [5+16+20*16+20*16^4], [5+16+20*16+20*16^4+20*16^5]$$

One generalization that I can come up with is following:
Start with the seed terms, as $$x_1=5, x_2=21$$ and then use the following rules:

To generate i-th term where $$i=2*k+1$$ [Odd] get:
$$x_i = x_{i-1} + 20*16^{2^{2k-2}}$$
To generate i-th term where $$i=2*k+2$$ [Even] get:
$$x_i = x_{i-1} + 20*16^{2^{2k-2}+1}$$

If the powers seem like ridiculous hack then feel free to replace them by any of the sequences that follow the required pattern on OEIS. I am listing some of them here just for completeness:

1- $$a(i) = floor((i-2)*sqrt(2))$$ Goes like 1, 2, 4, 5, 7, 8, 9, 11, ...
2- Numbers k such that 2*k + 9 is prime. Goes like 1, 2, 4, 5, 7, 10, 11, 14, ...
3- $$a(i) = floor(4*(i-2)/3)$$ Goes like 1, 2, 4, 5, 6, 8, 9, 10, 12, 13, ...

So, the next term can be any of the following depending on the pattern for the powers that you choose:

3.6893488e+20 if you choose the ridiculous hack for the powers
5391078741 if you choose 1st or 2nd sequences for the power
357913941 if you choose 3rd $$a(i)$$