csc-python-solutions/18/2 - Fast Fibbonacci.py
2021-02-17 14:23:08 +01:00

6 lines
213 B
Python

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]