You are viewing a single comment's thread. Return to all comments →
def fibonacci(N): s=2 a=1 b=2 for i in range(3,N+1): c=a+b a=b b=c if c<N: if c%2==0: s+=c else: break return s T=int(input()) for i in range(T): N=int(input()) print(fibonacci(N))
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 →