Last active
January 31, 2019 22:06
-
-
Save andrescabana86/739923f15423383809236540c709b535 to your computer and use it in GitHub Desktop.
This is the formula I followed up -> Fn = {[(√5 + 1)/2] ^ n} / √5
This file contains hidden or 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
import math | |
def fib(n): | |
return int(round(pow(((1 + math.sqrt(5)) / 2), n) / math.sqrt(5))) | |
# complexity O(n) | |
# space O(n) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment