title: Check if an int is prime Java
body: <p><strong>sorry for the "fix my code" post</strong></p>
  
  <p>EDIT: related more to syntax of a <code>for</code> loop than prime numbers, also solved now.</p>
  
  <p>My task is to take an int from the console and print out (on separate lines) all the prime numbers from 1 to n inclusive.
  My method starts at n, checks if its prime, then increments n down by one and loops until n=2.
  To check if a number is prime I run a loop, checking is the remainder of diving the number by x is equal to zero, with x starting at 2 and stopping at root(n).
  Now this all works in theory, and reading my code I don't see where it goes wrong.</p>
  
  <pre><code>public class Prime {
  public static boolean isPrime(int n) {
      boolean result = true;
      for (int x = 2; x&gt;=sqrt(n); x++) {
          if ((n % x) == 0) {
              result = false;
              break;
          } else {
              x++;
          }
      }
      return result;
  }
  
  public static void main(String[] args) {
      Scanner intIn = new Scanner(System.in);
      int i = intIn.nextInt();
      while (i&gt;=2) {
          if (isPrime(i)) {
              System.out.println(i);
              i--;
          } else {
              i--;
          }
      }
    }
  }
  </code></pre>
  
  <p>For example an input of 10 will return 10 (along with 9,8,7,6,5,3), even though isPrime() checks if 10 % 2 == 0, then sets <code>result</code> to false.
  What am I missing here??</p>
  
  <p>Again I apologise for the annoying (slightly duplicate) question.</p>