Skip to content

Instantly share code, notes, and snippets.

@bennett39
Last active July 10, 2022 13:54
Show Gist options
  • Save bennett39/4fdf872f941267ce8e5f3f998747af22 to your computer and use it in GitHub Desktop.
Save bennett39/4fdf872f941267ce8e5f3f998747af22 to your computer and use it in GitHub Desktop.
def fib(n):
"""Calculate the Nth fibonacci number.
Intentionally don't use dynamic programming. Goal is to simulate a long-running task.
"""
if n < 0:
raise ValueError('Negative numbers are not supported')
elif n == 0:
return 0
elif n <= 2:
return 1
return fib(n - 2) + fib(n - 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment