Interesting post. If I follow along with your code, I get about 1.22 seconds for the 2,000,000 case. However, running the built-in Fibonacci function in the Wolfram Language can do it in 0.02 seconds on the same machine (Fibonacci[2000000]). I suspect this is because of pre-computation (cached values), but even the 10^9 case only takes 7.27 seconds in the WL.

I create awesome software at Wolfram Research, makers of Mathematica, Wolfram|Alpha, Wolfram Cloud, and many other products and services.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store