From 331f56fe1ab3c95d14d336fa1874febe48db29a8 Mon Sep 17 00:00:00 2001 From: Allen Yao Date: Thu, 1 Sep 2022 23:06:32 -0400 Subject: [PATCH 1/2] fixed negative case --- fib.py | 1 + 1 file changed, 1 insertion(+) diff --git a/fib.py b/fib.py index 421cfab..8c85e64 100644 --- a/fib.py +++ b/fib.py @@ -6,6 +6,7 @@ Negative numbers should return None """ def fibonacci(position): + if position < 0: return None if(position == 1 or position == 2): return 1 return fibonacci(position - 1) + fibonacci(position - 2) From 095c4c5bd2a474e85550bea534a2e37217590e1c Mon Sep 17 00:00:00 2001 From: Allen Yao Date: Thu, 1 Sep 2022 23:07:58 -0400 Subject: [PATCH 2/2] fixed 0 case --- fib.py | 1 + 1 file changed, 1 insertion(+) diff --git a/fib.py b/fib.py index 8c85e64..857ba4c 100644 --- a/fib.py +++ b/fib.py @@ -7,6 +7,7 @@ """ def fibonacci(position): if position < 0: return None + if position == 0: return 0 if(position == 1 or position == 2): return 1 return fibonacci(position - 1) + fibonacci(position - 2)