Created
October 13, 2016 15:17
-
-
Save SahilKadam/48ac192fa0d2f2a0363daf293bf9895a to your computer and use it in GitHub Desktop.
This question expands on our earlier Fibonacci Lite challenge. While the goal of Fibonacci Lite was to understand recursion, this challenge is about solving problems efficiently with dynamic programming. The difference in this challenge is that each test case will consist of many inputs instead of just one. Furthermore, we're allowing larger val…
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
from math import sqrt | |
def fibo(n): | |
return (((1+sqrt(5))**n - (1-sqrt(5))**n)/(2**n*sqrt(5))) | |
while True: | |
try: | |
n = int(input().strip()) | |
print (int(fibo(n))) | |
except(EOFError): | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment