Fibonacci Sequence

Back to homepage

Project Overview

Write a program to find a specific number from the Fibonacci sequence.

The Fibonacci sequence is a series of numbers where, starting with 0 and 1, each number is the sum of the previous two numbers. Your program should take user input to get a specific number from the sequence (so, if the user types 6, they should get the sixth number in the sequence, the sum of 5 and 8, which is 13.)

This challenge started 2020 Dec 08 and ended 2020 Dec 15.

Submissions

Kat Crawford

def convert(a):
    if (a==1):
        return 0
    elif (a==2):
        return 1
    elif (a>=3):
        return convert(a-1)+convert(a-2)
    else:
        print("This input is invalid.")

integer = int(input("Enter a number: "))
print(convert(integer))

Benjamin Lowry

fibonacci = [0, 1]
index = int(input(">"))
while len(fibonacci) < index:
    fibonacci.append(fibonacci[len(fibonacci) - 1] + fibonacci[len(fibonacci) - 2])
print(str(fibonacci[index - 1]))
        

Will Stark