title: Loops and Prime Numbers
body: <p>Write a program that prompts the user for an integer and then prints out all prime numbers up to that integer. For example, when the user enters 20, the program should print
  <code>2 3 5 7 11 13 17 19</code>
  Recall that a number is a prime number if it is not divisible by any number except 1 and itself.</p>
  
  <p>I am trying to write this program but I am having difficulties, can anyone show me how to write this code?
  This is what I have written but it is completely wrong.</p>
  
  <pre><code>import java.util.Scanner;
  
  public class PrimeNumbers
  {
      public static void main(String[] args)
      {
          Scanner in = new Scanner(System.in);
  
          System.out.print("Enter Integers: ");
          int x;
          int n = in.nextInt();
  
          for (int i = 2; i &lt; n ; i++)
          {
              x = i;
  
              if (n % i != 0 &amp;&amp; i % x != 0)
              {
                  System.out.println(i);
              }
              x--;
          }
      }
  }
  </code></pre>