fibonacci.py 248 B

123456789101112
  1. #!/usr/bin/env python3
  2. # Copyright 2009-2017 BHG http://bw.org/
  3. # simple fibonacci series
  4. # the sum of two elements defines the next set
  5. a, b = 0, 1
  6. while b < 1000:
  7. print(b, end = ' ', flush = True)
  8. a, b = b, a + b
  9. print() # line ending