Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Recursive fibonacci benchmark using top languages on GitHub. Parent comment
http://sarabander.github.io/sicp/html/1_002e2.xhtml (Ctrl-F "We can also formulate an iterative process for computing the Fibonacci numbers.")
Here's a Python implementation:
def fib(n): a = 1 b = 0 i = 0 while i < n: temp = a a += b b = temp i += 1 return a
There are no comments on this comment yet.
http://sarabander.github.io/sicp/html/1_002e2.xhtml (Ctrl-F "We can also formulate an iterative process for computing the Fibonacci numbers.")
Here's a Python implementation:
With that, fib(100000) takes half a second to compute on my machine.