You are viewing a single comment's thread. Return to all comments →
sorry for late advice - store the first fibbonachi numbers in memory and go thrue tests $-)
import functools @functools.lru_cache(maxsize=None) def fib(n): if n<=2: return 1 else: return fib(n-1) + fib(n-2) n = int(input().strip()) s=0 for i in range(3,n,3): _ = fib(i) if _<=n: s+=_ else: break print(_)
all works on slow but wise Python
Seems like cookies are disabled on this browser, please enable them to open this website
An unexpected error occurred. Please try reloading the page. If problem persists, please contact support@hackerrank.com
Project Euler #2: Even Fibonacci numbers
You are viewing a single comment's thread. Return to all comments →
sorry for late advice - store the first fibbonachi numbers in memory and go thrue tests $-)
all works on slow but wise Python