import itertools def fib(): a, b = 0, 1 while True: yield a a, b = b, a+b print list(itertools.islice(fib(), 20))
Standard input is empty
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181]
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!