You are viewing a single comment's thread. Return to all comments →
using namespace std; int main(){ int n; cin >> n; for (int a = 0; a < n; a++){ long n; cin >> n;
long sum = 0; long x1 =1, x2=2; while (x2 <=n){ if (x2 % 2 == 0){ sum += x2; } long next = x1+x2; x1=x2; x2 = next; } cout << sum << endl; } return 0;
}
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 →
include
include
using namespace std; int main(){ int n; cin >> n; for (int a = 0; a < n; a++){ long n; cin >> n;
}