Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions fib.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
Negative numbers should return None
"""
def fibonacci(position):
if(position == 1 or position == 2):
if position < 0:
return None
elif position == 0:
return 0
elif position == 1:
return 1
return fibonacci(position - 1) + fibonacci(position - 2)




else:
return fibonacci(position - 1) + fibonacci(position - 2)