Fibonacci, Generators and Python
2007 December 16
Python is so beautiful and elegant
def fib():
a, b = 0, 1
while 1:
yield b
a, b = b, a+b
if __name__ == '__main__':
f = fib()
for i in xrange(1000):
print f.next()
I agree… love the terse yet readable code. thx for posting.
Good internet site / will definitely visit again:D