Skip to content

Instantly share code, notes, and snippets.

@Raj39120
Created May 1, 2020 18:36
Show Gist options
  • Save Raj39120/6bdab6f57814af9c465fa78ab59be429 to your computer and use it in GitHub Desktop.
Save Raj39120/6bdab6f57814af9c465fa78ab59be429 to your computer and use it in GitHub Desktop.
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