fork(1) download
  1. from itertools import islice
  2.  
  3. def fib(a=0, b=1):
  4. while 1:
  5. yield a
  6. a, b = b, a+b
  7.  
  8. n = int(raw_input("How many numbers would you like to display:"))
  9. print
  10. for f in islice(fib(), n):
  11. print f
Success #stdin #stdout 0.03s 6404KB
stdin
10
stdout
How many numbers would you like to display:
0
1
1
2
3
5
8
13
21
34