def main(): index = eval(input("Enter an index for a fibonacci number: ")) # Find and display the Fibonacci number print("The Fibonacci number at index", index, "is", fib(index)) # The function for finding the Fibonacci number def fib(index): if index == 0: return 0 elif index == 1: return 1 else: return fib(index - 1) + fib(index - 2) main()
How can I finds the number of times the fib function is called.
number of time fib is call in fib(0) = 1
number of time fib is call in fib(1) = 1
then everytime the number of time fib is call will be
1 + two previous fib number of calls.
I know the logic but I don't know how to write the code.