logo

Crowdly

Is the following function tail-recursive? def fib (n: int, a: int = 0, b: int ...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

Is the following function tail-recursive?

def fib (n: int, a: int = 0, b: int = 1) -> int:

if n == 0:

return a

elif n == 1:

return b

else:

return fib(n - 1, b, a + b)

More questions like this

Want instant access to all verified answers on learning.monash.edu?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!