
import java.util.*;

/******************************************************************
 Factor.java: My first CS121 Program

 Name:     
 Login:    
 Course:   CS 121
 Section:  
 Date:     

 Description: This program reads in an integer from the user and
 prints out all the factors of the number. It is assumed that the
 number is positive.

*******************************************************************/

public class Factor {

	/******************************************************************
        This is the main method that gets the number from the user and then
        invokes the method for factoring. 
	******************************************************************/
	public static void main(String args[])
	{
	  int numberInput
	  Scanner keyboard = new Scanner(System.in);
	  
	  System.out.println("This program will break up a number into its prime factors.");
	  System.out.print("Enter the number: ");
	  numberInput = keyboard.nextInt();
	  
	  listFactors(numberInput);

	}//main
	
	/******************************************************************
        Method: listFactors
        Precondition:
          The parameter num is a positive integer.
        Postcondition:
          The factors of num are listed, one per line.
	******************************************************************
	public static void listFactors (int num)
	{
	 int divisor = 2;
	 
     System.out.println("The factors are:");
	 while (divisor < num);
	  {
	   while (divisor % num == 0)
	    {
	     num = num / divisor;
	     System.out.println(divisor);
	    }//while
	   divisor++
	  }//while

	}//listFactors
	
}//Factor


