Create 2 - Fast Fibbonacci.py

This commit is contained in:
Lukas Baumann 2021-02-17 14:23:08 +01:00 committed by GitHub
parent 34c647744f
commit 7565402ea6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -0,0 +1,5 @@
def Fibonacci(n):
sequence = [0, 1, 1] # Fibonacci(0) is 0, Fibonacci(1) and Fibonacci(2) are 1
for i in range(3, n+1):
sequence.append(sequence[i-1] + sequence[i-2])
return sequence[n]