fork download
  1. num = int(input("How many Fibonacci numbers do you want? "))
  2.  
  3. prev = 0
  4. for n, _ in enumerate(range(num), 1):
  5. if n == 1:
  6. this = 1
  7. else:
  8. this, prev = this+prev, this
  9. print(f"{n}. {this}")
  10.  
Success #stdin #stdout 0.02s 9232KB
stdin
13
stdout
How many Fibonacci numbers do you want? 1. 1
2. 1
3. 2
4. 3
5. 5
6. 8
7. 13
8. 21
9. 34
10. 55
11. 89
12. 144
13. 233