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.
well this won't give any timeouts but one test case is failing , i think it's because of inaccuracy we get in golden ratio while calculating it for very large term for e.g. the following code will generate 27th term as 37889062373143904 instead of 37889062373143906.
rectify it and you will get the correct code :)
Project Euler #2: Even Fibonacci numbers
You are viewing a single comment's thread. Return to all comments →
I used Binet's formula, changed to long in C++ and I still get a few timeouts. Any recommendations?
well this won't give any timeouts but one test case is failing , i think it's because of inaccuracy we get in golden ratio while calculating it for very large term for e.g. the following code will generate 27th term as 37889062373143904 instead of 37889062373143906. rectify it and you will get the correct code :)
sorry for late advice - store the first fibbonachi numbers in memory and go thrue tests $-)
all works on slow but wise Python
for i in range(3,n,3) I see what you did there, smart.