KeeganT

Ch6Ex2

Feb 19th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.49 KB | None | 0 0
  1. package ch6ex2;
  2. import java.util.Scanner;
  3.  
  4. public class Ch6Ex2
  5. {
  6.     public static void main(String args[])
  7.     {
  8.         int number;
  9.         Scanner sc=new Scanner(System.in);
  10.         System.out.print("Enter a number: ");
  11.         int num=sc.nextInt();
  12.         for(int c=2;c<num;c++)
  13.         {
  14.             while(num%c==0)
  15.             {
  16.                 System.out.println(c+" ");
  17.                 num=num/c;
  18.             }
  19.         }
  20.         if(num>2)System.out.println(num);
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment