title: Finding all the factors of a number in Java?
body: <p>"Write a program that reads an integer I and displays all its smallest factors in increasing order. For example, if the input integer is 120, the output should be as follows: 2, 2, 2, 3, 5.". At the beginning of the program, the user has to enter an integer identifying how many numbers will be factorized.  </p>
  
  <pre><code>import java.util.Scanner;
  
  public class Main {
  
      public static void main(String [] args){
  
          Scanner input = new Scanner(System.in);
  
          int size = input.nextInt();
  
          for(int i = 0; i &lt; size; i++){
  
              int a = input.nextInt();
  
              for(int j = 0; j &lt; a; j++){
                  if(a%j==0){
                      System.out.println(j);
                  }
              }
  
          }
          input.close();
  
      }
  
  }
  </code></pre>