We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
defsolve(a,b,n):x=(1+sqrt(5))/2y=(1-sqrt(5))/2first=((a/2)*(1-(1/sqrt(5)))+(b/sqrt(5)))*(x)**nsecond=((a/2)*(1+(1/sqrt(5)))-(b/sqrt(5)))*(y)**nreturnint((first+second).real)# why this shows me wrong but answer is correctans=first+secondreturnstr(int(ans.real))
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Fibonacci Finding (easy)
You are viewing a single comment's thread. Return to all comments →
simple recurrance relation formula
maths