# File: tuThFib.py # Author: Dr. Gibson # Date: 11/22/2016 # Section: N/A # E-mail: k.gibson@umbc.edu # Description: # This file contains python code that recursively implements # the Fibonacci sequence. FIB_FIRST = 0 FIB_SECOND = 1 INVALID = -1 def fib(num): # BASE CASES if num <= 0: return INVALID elif num == 1: return FIB_FIRST elif num == 2: return FIB_SECOND # RECURSIVE CASE else: return fib(num - 1) + fib(num - 2) def main(): num = int(input("What number of the Fibonacci sequence do you want? ")) ans = fib(num) print("The Fibonacci sequence's ", str(num) + "th number is:", ans) main()