Question PRG-PY-0071
HardWhat is the output of this program?
from functools import lru_cache
calls = 0
@lru_cache(maxsize=None)
def fib(n):
global calls
calls += 1
return n if n < 2 else fib(n - 1) + fib(n - 2)
print(fib(30), calls)
- A.
514229 31
- B.
832040 31
- C.
832040 1664079
- D.
832040 30
Sign up free to see the answer and a step-by-step explanation.