From 222eb92fd91d3f29b92cc49ecaaf9d44f6e73a1c Mon Sep 17 00:00:00 2001 From: Jarel Tey Date: Fri, 2 Sep 2022 14:00:29 -0400 Subject: [PATCH 1/2] fix zeroth case --- fib.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fib.py b/fib.py index 421cfab..c8dac03 100644 --- a/fib.py +++ b/fib.py @@ -6,7 +6,9 @@ Negative numbers should return None """ def fibonacci(position): - if(position == 1 or position == 2): + if position == 0: + return 0 + if (position == 1 or position == 2): return 1 return fibonacci(position - 1) + fibonacci(position - 2) From 5e03d353bf91616003dc727a0f17d4950b78ad98 Mon Sep 17 00:00:00 2001 From: tejasv23 <77163666+tejasv23@users.noreply.github.com> Date: Fri, 2 Sep 2022 14:06:48 -0400 Subject: [PATCH 2/2] added if statemnt to deal with negatives --- fib.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fib.py b/fib.py index 421cfab..23da3c5 100644 --- a/fib.py +++ b/fib.py @@ -6,6 +6,8 @@ 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)