Answer: What Comes Next? #400

The answer is B: 21.

The finished pattern: 1, 2, 3, 5, 8, 13, 21.
The finished pattern.

The rule

Each number is the two numbers before it added together. 1 + 2 = 3, 2 + 3 = 5, and so on. The famous Fibonacci sequence works like this, starting 1, 1, 2, 3, 5, 8.

The pattern as Python code

Here is a tiny Python program that follows the same rule. Type it into IDLE and run it to print the whole pattern, including the answer.

a, b = 1, 2
for step in range(7):
    print(a)
    a, b = b, a + b

When you run it, Python prints:

1
2
3
5
8
13
21

Pixel says: Try changing a number in the code and run it again. Can you make the pattern go on for 20 steps? Meow!