Last active
August 20, 2020 04:08
-
-
Save ellisandrews/da28dac5de275e60c0189bc78c9d7546 to your computer and use it in GitHub Desktop.
Exponential time complexity
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
def nth_fibonacci_term(n: int) -> int: | |
"""Recursively finds the nth term in the Fibonacci sequence. Assumes positive n.""" | |
# Base case -- The first two numbers of the sequence are {0, 1} | |
if n <= 2: | |
return n - 1 | |
return nth_fibonacci_term(n - 1) + nth_fibonacci_term(n - 2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment