 License Public Domain
 Lines 30
Euler02 (5)
##### Related Project Euler 2 Euler02, C++ Euler Problem 2 Euler02 C++ Euler28, C++, Analytical Solution
##### Permissions Owner: jsimones Group Owner: SnortSnort Viewable by Everyone Editable by All Siafoo Users

# Project Euler 2 0

 Language C++
# 's
` 1/* 2Even Fibonacci numbers 3Problem 2 4Each new term in the Fibonacci sequence is generated by adding the previous two 5terms. By starting with 1 and 2, the first 10 terms will be: 6 71, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... 8 9By considering the terms in the Fibonacci sequence whose values do not exceed10four million, find the sum of the even-valued terms.1112*/13#include <iostream>14using namespace std;1516int main ()17{18  // Declare some shit; start with first two terms in sequence before the loop19  int i1 = 1;20  int i2 = 2;21  int i3 = 3;22  int sum = i2;2324  // Loop through sequence until term <= 4e6, add to sum if term is even25  while (i3 <= 4.0e6) {26    i3 = i1 + i2;2728    if (i3 % 2 == 0) {29      sum += i3;30    }3132    i1 = i2;33    i2 = i3;34  }35  cout << sum << endl;36  return 0;37}`