What is the next number in the series 2, 3, 5, 9, 17, ...?
33. The differences are 1, 2, 4, 8, which double each time, so the next difference is 16 and 17 + 16 = 33. Each term is also 2^n + 1, or double the previous term minus 1.
Explain it simply
When the terms grow faster and faster, look at the differences between consecutive terms. If the differences themselves form a familiar pattern (constant, increasing by a fixed amount, or doubling), extend that pattern one step and add it on. Then check the rule with a second description if you can.
Example
Question: 2, 3, 5, 9, 17, ?
- Differences: 3 - 2 = 1, 5 - 3 = 2, 9 - 5 = 4, 17 - 9 = 8.
- They double: the next difference is 16.
- Next term = 17 + 16 = 33.
Second check: each term = 2 x previous - 1. 2 x 17 - 1 = 33. Also each term is 2^n + 1 for n = 0, 1, 2, 3, 4, 5.
const s = [2];
for (let i = 0; i < 5; i++) s.push(2 * s[s.length - 1] - 1);
console.log(s); // Output: [2,3,5,9,17,33]What to say in the interview
"The differences are 1, 2, 4, 8, doubling each time, so the next difference is 16 and the term is 33. The rule 'double minus one' gives the same answer."
Common mistakes
- Assuming the differences grow by a constant and adding 10 or 12.
- Stopping at one rule without cross-checking against all the terms.