# What is the next number in this sequence? (My first)

This is my first attempt at a question. Please let me know what you think of it, I came up with the idea for it while trying to figure out some of the other sequence questions here.

1, 2, 5, 10, 21, 42, 85, ?

I can add a hint if needed.

-P.S. I have not been around for the longest time so sorry if this has been asked before

• Hi Steven. Welcome to the site and great that you're willing to put in content. As you have asked for feedback: generally speaking "number series" puzzles are not the most welcome puzzles as they are often either too vaguely defined or sometimes just boring. If you're willing to pack puzzle ideas into more complex / structured / bigger puzzles, you will earn more community respect. – BmyGuest Jul 29 '16 at 15:35
• Steven, I think I've got it, please comment below my answer (way down low :D). – owlswipe Jul 30 '16 at 3:27

This answer is prompted by user f'' who gave a hint:

Try converting to binary.

So I did...

1

1

2

10

5

101

10

1010

21

10101

42

101010

85

1010101

The pattern becomes obvious at this point:

The sequence is a binary number n digits long starting with a 1 and alternating 1s and 0s (then converted back to decimal, of course).

10101010 which is 170 in decimal.

Double if it is odd and double+1 if it is even works because when it is odd that means the last digit in binary is a 1. So to continue the sequence we must add a zero to the end. This is equivalent to multiplying by 2. When it is even we need to add a 1 on the end. We know that adding a 0 on the end is multiplying by 2 so adding a 1 on the end is multiplying by 2 and adding 1.

and

My other answer of $f(n)=2^n+f(n−2)$ works by considering the power expansion of a binary number. For any given member of the sequence you can make the element two further on by adding a new power of 2 which is 2 orders of magnitude higher than the previous highest. So if you look at $f(5) = 42 = 101010 = 2^5+2^3+2^1$ then you can add a new power of 2 to the beginning to give $2^7+2^5+2^3+2^1 = 1010101 = 85$.

• This was the pattern that I did have in mind when I came up with the question. Thanks to f" for the suggestion to it. – Steven Wiberg Aug 9 '16 at 13:40

170 Explanation is that all odd numbers are multiplied by 2 while all even numbers are multiplied by 2 and then added by 1.

• Well then not the way I came up with this one, but a valid answer none the less – Steven Wiberg Jul 29 '16 at 15:16
• So, it's not the correct answer? – Sid Jul 29 '16 at 15:16
• @Sid I'm willing to wager that whatever algorithm the original author had in mind, it would most likely reduce to yours. – Deepak Jul 29 '16 at 15:18
• Try converting to binary. – f'' Jul 29 '16 at 15:48
• @f'': you should – Steven Wiberg Jul 29 '16 at 16:25

The next term is:

$170$

Since another formulation of the solution was requested this series can be expressed as:

$f(n) = 2^n + f(n-2)$ for $n \ge 0$

and

Whereby we assume $f(-1) = f(-2) = 0$ when needed for the main formula to be well formed.

So to spell them out more clearly:

First term:

$f(0) = 2^0 + f(-2) = 1 + 0 = 1$

Second Term:

$f(1) = 2^1 + f(-1) = 2 + 0 = 2$

Third Term:

$f(2) = 2^2 + f(0) = 4+1 = 5$

Fourth Term:

$f(3) = 2^3 + f(1) = 8+2 = 10$

Fifth Term:

$f(4) = 2^4 + f(2) = 16+5 = 21$

Sixth Term:

$f(5) = 2^5 + f(3) = 32+10 = 42$

Seventh Term:

$f(6) = 2^6 + f(4) = 64+21 = 85$

Eight Term:

$f(7) = 2^7 + f(5) = 128+42 = 170$

• Maybe, this is it. Sort of explains it in pure mathematical way.. – Sid Jul 29 '16 at 16:19
• I think f''s suggestion on binary is more likely. This is a nice pure maths difference equation but the binary answer (which I will post if f'' doesn't) is by far the most elegant solution. – Chris Jul 29 '16 at 16:25
• Yeah... the binary thing is beautiful. Maybe that was the author's logic. It makes a brilliant pattern. – Sid Jul 29 '16 at 16:28
• The other quite nice thing is that you can see it in my answer by the nature of the recurrence relationship (or just by doing the substitutions iteratively until you get to the base case). – Chris Jul 29 '16 at 16:36

The number is

171

Explanation

Each number is double the last plus 1, 171=85•2+1

• 2, 10 and 42 do not pass this formula. – bg6471 Jul 30 '16 at 6:48