Skip to content
Open
Show file tree
Hide file tree
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
22 changes: 8 additions & 14 deletions fib.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@

"""
Fibonacci number generator
When given a position, the function returns the fibonacci at that position in the sequence.
The zeroth number in the fibonacci sequence is 0. The first number is 1
Negative numbers should return None
"""
def fibonacci(position):
if(position == 1 or position == 2):
return 1
return fibonacci(position - 1) + fibonacci(position - 2)




if position < 0:
return None
elif position == 0:
return 0
elif position == 1:
return 1
else:
return fibonacci(position - 1) + fibonacci(position - 2)
1 change: 1 addition & 0 deletions github-assignment-python
Submodule github-assignment-python added at 5eddda
1 change: 1 addition & 0 deletions hw2repo
Submodule hw2repo added at a9a804