title: Project Euler 2 in Java
body: <pre><code>public class Euler2 {
      public static void main(String[] args) {
          int Num1 = 0;
          int Num2 = 1;
          int sum = 0;
  
          do
          {
              sum = Num1 + Num2;
              Num1 = Num2;
              Num2 = sum;
  
              if (Num2 % 2 == 0)
                  sum = sum + Num2;
          }
          while (Num2 &lt; 4000000);
  
          System.out.println(sum);
      }
  }
  </code></pre>
  
  <p>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:</p>
  
  <p>1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...</p>
  
  <p>By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.</p>
  
  <p>I don't feel like I coded it wrong but the answer I'm getting is 5702887 and I know it should be 4613732.</p>