# File: fib.py # compute and print the first few Fibonacci numbers # # Matt Bishop, MHI 289I, Fall 2021 # # # read in the number to go to # try: count = int(input("How many Fibonacci numbers should I show? ")) except: print("Please enter a positive integer!") else: if count <= 0: print("That's not a positive integer!") else: # initialize series fn1 = 0 fn2 = 1 print("Fibonacci number 1 is", fn1) if count > 1: print("Fibonnaci number 2 is", fn2) # compute the sequence and print the terms for i in range(count-2): # get next Fibonacci number fn = fn1 + fn2 # announce it print("Fibonacci number", i+3, "is", fn) # advance in seuence fn1 = fn2 fn2 = fn