title: In Java, how to print divisor numbers?
body: <p>I want to print the divisors of a user input value between 1 and 10000.  </p>
  
  <pre><code>import java.util.Scanner;
  
  public class Divisors {
  
      public static void main(String[] args) {
  
          Scanner scan = new Scanner(System.in);
          int Range;
          int Divisor;
  
          while(true) {
  
              System.out.print("Please insert a number between 1 and 10000: ");
              Range = scan.nextInt();
  
              if (Range &lt; 1 || Range &gt; 10000)
              System.out.println("Wrong choice");
  
              else
                  break;
          }
  
  
          Divisor = 0;    // Start counting Divisor from Zero
  
          for (int loop = 1; loop &lt;= Range; loop++) {
              if (Range % loop == 0)
                  Divisor++;
                  System.out.println("loop);      
              }
  
          System.out.println("Total number of divisors of " + Range + " is " + Divisor);
  
      }
  }
  </code></pre>
  
  <blockquote>
    <p>I have problem here with command <strong>System.out.println("loop);</strong>. 
    I want to print all the divisors, like if a user inserted 10, then the
    output should show something like:</p>
  </blockquote>
  
  <p>!</p>
  
  <pre><code>Please insert a number between 1 and 10000: 10
  1
  2
  5
  10
  Total number of divisors of 10 is 4
  </code></pre>
  
  <p>!
  !</p>
  
  <blockquote>
    <p>But the current output is:</p>
  </blockquote>
  
  <p>!</p>
  
  <pre><code>Please insert a number between 1 and 10000: 10
  1
  2
  3
  4
  5
  6
  7
  8
  9
  10
  Total number of divisors of 10 is 4
  </code></pre>
  
  <p>!
  !</p>
  
  <blockquote>
    <p>so how to print <strong>loop</strong> only when the <strong>(Range % loop == 0)</strong> is true??</p>
  </blockquote>