fork download
  1. class Fib(object):
  2. def __init__(self):
  3. self.a,self.b=0,1
  4. def __iter__(self):
  5. return self
  6. def __next__(self):
  7. self.a,self.b=self.b,self.a+self.b
  8. if self.a>100000:
  9. raise StopIteration()
  10. return self.a
  11.  
  12. for n in Fib():
  13. print(n)
  14.  
  15. # your code goes here
  16. # your code goes here
  17. # your code goes here
Success #stdin #stdout 0.09s 14132KB
stdin
Standard input is empty
stdout
1
1
2
3
5
8
13
21
34
55
89
144
233
377
610
987
1597
2584
4181
6765
10946
17711
28657
46368
75025