fork download
  1. def fib(n):
  2. a, b = 0, 1
  3. for _ in range(n):
  4. yield a
  5. a, b = b, a + b
  6.  
  7. print(list(fib(10)))
  8.  
Success #stdin #stdout 0.02s 9220KB
stdin
Standard input is empty
stdout
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34]