Tue May 30 2017
Copied to clipboard! Copy reply
  • 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

import sys


def fib(n):
    a, b = 0, 1
    while a < n:
        print(a)
        a, b = b, a+b


try:
    n = int(sys.argv[1])
except (IndexError, ValueError) as e:
    raise Exception("Please specify a numerical argument;", e)


print("Creating fibonacci sequence limited to: ", n)
fib(n)