137 karma · joined January 28, 2013
Because then it would take more time to brute force. I mean if hashes were near instant then even without any theocratical collision that wouldn't be good, that hash would fall faster than a slower one!
[Recursive - 7921 ms], [Iteratiive - 8078 ms]
So the difference is negligible.
Anyway I forked the original code, added an iterative version based on the comment by (Nick Craig Wood) (https://github.com/AeonAxan/benchmarking_fibonacci)
Here are the benchmarks [recursive fib: 7,765 ms] | [iterative fib: 8,047 ms] | [analytic opt fib: 54,875] | [analytic fib: 103,937 ms] |
And it appears that the recursive version is faster than the naive iterative version by a few hundred milliseconds.