January 2009
1 post
Elegant Fibonacci Iterator
After a bunch of versions of Fibonacci functions months back, the following iterator appeared in my notebook. def fib(): future = [0, 1] while True: future.append(sum(future)) yield future.pop(0) Though of no particular engineering marvel. It is, at O(n), slower than the best case O(log(n)) I can do using matrix multiplication of powers of two. I find it particularly...
Jan 25th