title: Project Euler #10 Java solution not working
body: <p>I'm trying to find the sum of the prime numbers &lt; 2,000,000. This is my solution in Java but I can't seem get the correct answer. Please give some input on what could be wrong and general advice on the code is appreciated.</p>
  
  <p>Printing 'sum' gives: 1308111344, which is incorrect.</p>
  
  <p>Edit: 
  Thanks for all the help. Changed int to long and &lt; to &lt;= and it worked flawlessly, except for being an inefficient way of finding prime numbers :)</p>
  
  <pre><code>/*
  The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
  Find the sum of all the primes below two million.
  */
  class Helper{
   public void run(){
    Integer sum = 0;
    for(int i = 2; i &lt; 2000000; i++){
     if(isPrime(i))
      sum += i;   
    }
    System.out.println(sum);
   }
  
   private boolean isPrime(int nr){
    if(nr == 2)
     return true;
    else if(nr == 1)
     return false;
    if(nr % 2 == 0)
     return false;
  
    for(int i = 3; i &lt; Math.sqrt(nr); i += 2){
     if(nr % i == 0)
      return false;
    }  
    return true;  
   }
  }   
  class Problem{
   public static void main(String[] args){
    Helper p = new Helper();
  p.run();
  }
  }
  </code></pre>