title: the code doesn't stop running, in Java
body: <p>I'm solving problem 10 in project Euler in Java, which is </p>
  
  <blockquote>
    <p>"The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. <br />
    Find the sum of all the primes below two million."</p>
  </blockquote>
  
  <p>and my code is </p>
  
  <pre><code>package projecteuler_1;
  
  import java.math.BigInteger;
  import java.util.Scanner;
  
  public class ProjectEuler_1 {
  
   public static void main(String[] args) {
      int sum = 0, i = 2;
      while (i &lt;= 2000000) {
          if (isPrime(i)) {
              sum += i;
          }
          i++;
      }
      System.out.println(sum);
   }
  
   public static boolean isPrime(int n) {
      int i, res;
      boolean flag = true;
      for (i = 2; i &lt;= n / 2; i++) {
          res = n % i;
          if (res == 0) {
              flag = false;
              break;
          }
      }
      return flag;
   }
  }
  </code></pre>
  
  <p>but the code doesn't give me any results, it doesn't stop running. Why?</p>