Problem
You have been given a fib()
function that calculates the nth number in the Fibonacci sequence. The function works correctly with smaller numbers such as 4, 5, 10, etc. However, when we want to calculate the numbers much ahead in the series such as , it takes too long to finish computing.
The Fibonacci Sequence: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55…
Written as a rule, the expression is:
Get hands-on with 1400+ tech skills courses.