From 7565402ea6cee2ba73174f2661b20231fe581726 Mon Sep 17 00:00:00 2001 From: Lukas Baumann Date: Wed, 17 Feb 2021 14:23:08 +0100 Subject: [PATCH] Create 2 - Fast Fibbonacci.py --- 18/2 - Fast Fibbonacci.py | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 18/2 - Fast Fibbonacci.py diff --git a/18/2 - Fast Fibbonacci.py b/18/2 - Fast Fibbonacci.py new file mode 100644 index 0000000..c7967e7 --- /dev/null +++ b/18/2 - Fast Fibbonacci.py @@ -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]