4 ms·
The code here isn't the best in any language. A purely recursive Fibonacci is a terribly inefficient way to do the calculation because it will recompute every `
by ChrisRackauckas 9y ago
The code here isn't the best in any language. A purely recursive Fibonacci is a terribly inefficient way to do the calculation because it will recompute every `fib(n-1)` a few times, making the complexity exponential. But that's what makes it great benchmark of recursion. People then try replacing the code with an O(n) vectorized version and say "hey, we beat Julia!" but that completely misses the point that (1) yes, you can do the O(n) version in Julia too and it will be faster but also (2) this is a test of recursion with the name "recursion" in the name.