Answer
def fib(n):
return fibHelper(n, 0, 1)
def fibHelper(n, a = 0, b = 1):
if n == 0
return a
if (n == 1)
return b
return fib(n - 1, b, a + b)
Work Step by Step
Here the fib function just calls the fibHelper function and the fibHelper function makes only one recursive call at the very end of the program, there is no other operation that need to be done after that call hence the function is tail recursive.