You are viewing a single comment's thread. Return to all comments →
import sys t = int(input().strip()) for a0 in range(t): n = int(input().strip()) s = [1, 1] r = 0 for i in range(3, n + 2): if i >= 3 and s[i - 2] + s[i - 3] <= n: s.append(s[i - 2] + s[i - 3]) if i % 3 == 0: r += s[i - 1] else: break print(r)
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #2: Even Fibonacci numbers
You are viewing a single comment's thread. Return to all comments →