Skip to content

Instantly share code, notes, and snippets.

@cristinelpopescu
Created March 1, 2021 15:03
Show Gist options
  • Save cristinelpopescu/c4d36cda59b9ea9d91feb1c369039f89 to your computer and use it in GitHub Desktop.
Save cristinelpopescu/c4d36cda59b9ea9d91feb1c369039f89 to your computer and use it in GitHub Desktop.
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