diff --git a/fib.py b/fib.py index 50722c2..5b4963c 100644 --- a/fib.py +++ b/fib.py @@ -6,11 +6,12 @@ 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) - # Test cases print("The 1st Fibonacci number: ", fibonacci(1)) print("The 21st Fibonacci number: ", fibonacci(21))