Skip to content

Instantly share code, notes, and snippets.

@keichi
Created May 8, 2020 03:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keichi/4cb14484ab68c685ec729a6cf8232530 to your computer and use it in GitHub Desktop.
Save keichi/4cb14484ab68c685ec729a6cf8232530 to your computer and use it in GitHub Desktop.
cpdef fibonacci(int n):
if n < 2:
return n
cdef int a = 0
cdef int b = 1
for i in range(2, n + 1):
a, b = b, a + b
return b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment