Advertisement
Aleks_Tor

Prime Factors [first one]

May 10th, 2021
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.57 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5.     public static void main(String[] args) {
  6.         Scanner scanner = new Scanner(System.in);
  7.         int N = scanner.nextInt();
  8.         int temp = N;
  9.         for (int i=1; i<=N; i++){
  10.             if (temp%2==0){
  11.                 System.out.println(2);
  12.                 temp/=2;
  13.             } else if (temp%3==0){
  14.                 System.out.println(3);
  15.                 temp/=3;
  16.             } else if (temp%5==0){
  17.                 System.out.println(5);
  18.                 temp/=5;
  19.             }
  20.         }
  21.         }
  22.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement