Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.lang.Math;
- public class Factoring
- {
- public static void main(String[] args)
- {
- Scanner keyboard = new Scanner (System.in);
- long theDivisor;
- long theQuotient;
- while(true)
- {
- System.out.print("Enter a number >=2: ");
- theQuotient = keyboard.nextLong();
- theDivisor = 2;
- if( theQuotient < 2)
- {
- break ;
- }
- System.out.print(theQuotient + " = ");
- while( theQuotient > 1)
- {
- if(theQuotient % theDivisor == 0)
- {
- System.out.print(theDivisor);
- theQuotient = theQuotient / theDivisor;
- if(theQuotient > 1)
- {
- System.out.print(" * ");
- }
- }
- else
- {
- theDivisor ++;
- }
- }
- System.out.println();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement