You are viewing a single comment's thread. Return to all comments →
Python
t = int(input().strip()) n=[] for a0 in range(t): n.append(int(input().strip())) for i in range(t): fib =[1,2] j=0 sum =2 while(fib[j+1] < n[i]): if((fib[j] + fib[j+1]) < n[i]): fib.append(fib[j] + fib[j+1]) if((fib[j] + fib[j+1])%2 == 0): sum = sum + fib[j] + fib[j+1] j+=1 else: break if(n[i] > 2): print(sum)
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 →
Python