Question DSA-REC-0004
EasyWhat is the output of this code?
def fib(n):
return n if n < 2 else fib(n - 1) + fib(n - 2)
print(fib(6))
- A.
8
- B.
13
- C.
Show answer and explanation
Answer: A
fib(6) with fib(0) = 0, fib(1) = 1 gives 0, 1, 1, 2, 3, 5, 8.