The biggest problem with the fibonacci series is the time complexity of the algorithm, when you use simple recursion, you will be recalculating everything and doing a lot of double work. This is because when you calculate fib(n) using
int fib(int n) {
if (n < 2) { return 1; }
return fib(n-1) + fib(n-2)
}
you will be calculating fib(n-1), which calculates fib(n-2) and fib(n-3). But for calculating fib(n), you will already calculate fib(n-2). In order to improve this, you would need to store the temporary results. This is usually easier using iteration and starting from i = 0 going up to n. This way you can easily store the last two results and avoid calculating the same values over and over.
An easy way to see if an algorithm is efficient is to try and solve it for a few increasingly harder examples. You can also calculate it more accurately. Take the fibonacci example above. Calling fib(n) would take the complexity O(fib(n)) = O(fib(n-1)) +O(fib(n-2)) + 1
(let's just take 1 for the addition). Let's assume that O(fib(0)) = O(fib(1)) = 1
. This means O(fib(2)) = 3, O(fib((3)) = 5, O(fib(4)) = 9
. As you can see, this series would go up faster than the fibonacci series itself! This means a huge amount of increasing complexity.
When you would have an iterative algorithm with a for loop from 0 to n, your complexity would scale in the order of n, which would be way better.
For more information, check out the big-o notation.