Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Using Fibonacci with a negative number

What if the user calls it with -3 ? We get the result to be 1. We don’t want that.

from fibonacci import fib

print(fib(10))
print(fib(-3))

Output:

55
1