A function returns 0 for n = 0, 1 for n = 1, and fib(n-1) + fib(n-2) for larger n. What is fib(10)?

Answer and explanation

Correct answer: C. 55

  1. Step 1: The sequence is 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55.
  2. Step 2: fib(10) = 55.
Answer
55.
Why not the others: 34, 89 and 56 do not fit.

Practise more Python programming and algorithms.

Free questions with an explanation for every one, and full timed Saudi Secondary School Certificate mock tests.

A function returns 0… | Saudi Secondary School Certificate