# Fibonacci is a sequence that starts with 0 and 1 # Every number in the sequence is the sum of the previous 2 numbers # 0 1 1 2 3 5 8 13 21 34 55 # this function will look for the number in the sequence at an index specified by the user and return it def fibonacci(index): # start the sequence with 0 and 1 already in indices 0 and 1 terms = [0,1] # set i to the next index to find, currently 2 i = 2 # keep going until i reaches the index the user is looking for while i <= index: # there is no number at the current index # but we can add the 2 numbers right before by accessing the the list at indices i-1 and i-2 terms.append(terms[i-1] + terms[i-2]) # increment i to keep going i = i+1 # now terms contains the fibonacci sequence up until the index provided by the user, which we can print if we want to print(terms) # we return the element at that index return terms[index] number = int(input("# in Fibonacci Sequence: ")) print(fibonacci(number))