Created
May 1, 2020 18:36
-
-
Save Raj39120/6bdab6f57814af9c465fa78ab59be429 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fibonacci(): | |
num = int(input("Enter how many numbers from the fibonacci sequence you would like to generate: ")) | |
i = 1 | |
if num == 0: | |
fib = [] | |
return fib | |
elif num == 1: | |
fib = [1] | |
return fib | |
elif num == 2: | |
fib = [1, 1] | |
return fib | |
elif num > 2: | |
fib = [1, 1] | |
while i < (num - 1): | |
fib.append(fib[i] + fib[i-1]) | |
i += 1 | |
return fib | |
print(fibonacci()) | |
input() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment