Project Euler Problem 2 Java Solution - Even Fibonacci Numbers

The basic skill that all programmers and developers should have is logic. This is the basic that enables us to solve more complex problems to deliver solutions to clients. Project Euler is a good source of problems to develop our logic. If we are looking at problems in the project and are stuck, below is a solution to Euler Problem #2 with title - Even Fibonacci Numbers.

Project Euler Problem #2 - Even Fibonacci Numbers

Below is the problem statement of problem number two in the Euler Project.
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, ...
By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.
A simple implementation to achieve the solution is given below.
/**
 * A simple implementation to solve Euler Problem #2 - Even Fibonacci numbers.
 */
public class EulerProblemSolution {
    public static void main(String[] args) {
        int maxNumber = 4*1000*1000;
        int a = 1;
        int b = 2;
        int c = 2;
        long answer = 2;
        while (c <= maxNumber) {
            c = a + b;
            a = b;
            b = c;
            if ( c <= maxNumber && (c % 2) == 0) {
                answer+= c;
            }
        }
        System.out.println(answer);
    }
}

This program outputs the answer to the problem which is:

4613732