/* http://projecteuler.net/
 *
 * Problem 2
 * Find the sum of all the even-valued terms in the Fibonacci sequence
 * which do not exceed one million.
 *
 * Solution by Melkor (Filip Niksic, fniksic@gmail.com)
 *
 **/

#include <iostream>

using namespace std;

int main() {
    long long sum(0), a(0), b(1), c(1);

    do {
	if (c % 2 == 0) sum += c;

	a = b;
	b = c;
	c = a + b;
    } while (c <= 1000000);

    cout << "Result: " << sum << endl;

    return 0;
}
