Created
January 14, 2020 23:49
-
-
Save alexcrist/5e16341eba1d5bc41a10c0ea541a5e1a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Returns the nth iteration of the fibonacci sequence | |
# n: 0 1 2 3 4 5 6 | |
# output: 1 1 2 3 5 8 13 | |
def fibonacci(n): | |
# Base case | |
if n == 0 or n == 1: | |
return 1 | |
# Recursive case | |
return fibonacci(n - 1) + fibonacci(n - 2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment