License Public Domain
Lines 20
Keywords
Euler02 (5) Fibonacci (1)
Permissions
Owner: neary
Group Owner: SnortSnort
Viewable by Everyone
Editable by neary and "SnortSnort" Group Members
Hide
Meet people who work on similar things as you – get help if you need it Join Siafoo Now or Learn More

Euler Problem 2 Atom Feed 0

# 's
 1#include <iostream>
2using namespace std;
3
4int main()
5{
6 const int max_term = 4e6;
7 int term1 = 1;
8 int term2 = 2;
9 int new_term = 0;
10 int sum = 2;
11 for (int i = 0; term1 + term2 <= max_term; i++)
12 {
13 new_term = term1 + term2;
14 if (new_term % 2 == 0)
15 sum += new_term;
16
17 term1 = term2;
18 term2 = new_term;
19 }
20 cout << sum << endl;
21 return 0;
22}