educative.io

Why should I prefer a recursive function which is 1000 times slower with respect to a solution which uses a loop..?

This type of “function calls function itself” solution is extremely slow…! Even if you want to find 50th term of Fibonacci series, you have to wait half an hour. But if you solve this problem with a while or for loop, it calculates in seconds even if you want to solve 500th term of Fibonacci. Why do you advice this solution by a recursive function?


Course: Full Speed Python - Learn Interactively
Lesson: Challenge 5: Compute nth Fibonacci Number - Full Speed Python