/**
 * Each new term in the Fibonacci sequence is generated by adding the previous two terms.
 * By starting with 1 and 2, the first 10 terms will be:1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
 * <p>
 * By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the
 * even-valued terms.
 *
 * @author David Clutter
 */
public class Problem0002 {

    public static void main(final String[] args) {
        int previous = 1;
        int current = 2;
        long sum = current;
        while(current <= 4_000_000) {
            final int temp = previous + current;
            previous = current;
            current = temp;
            if(current % 2 == 0) {
                sum += current;
            }
        }
        System.out.println(sum);
    }
}
Add problem0002