Created
March 1, 2021 15:03
-
-
Save cristinelpopescu/c4d36cda59b9ea9d91feb1c369039f89 to your computer and use it in GitHub Desktop.
This file contains hidden or 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("How many numbers you want to generate?: ")) | |
i = 1 | |
if num == 0: | |
fib = [] | |
elif num == 1: | |
fib = [1] | |
elif num == 2: | |
fib = [1,1] | |
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