fibonacci.py 378 Bytes
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys

if len(sys.argv) == 1 or not sys.argv[1].isnumeric() or int(sys.argv[1]) <= 0:
msg = """\
Usage: {:s} nbr_int
nbr_int: Un nombre entier supérieur à 0""".format(sys.argv[0])
print(msg)
sys.exit(1)

a,b = 0,1

while b < int(sys.argv[1]):
print(b)
a,b = b,a+b

print("b/a = {:1.15f}".format(b/a))

sys.exit(0)