vladovip

Prime Numbers1 _ Java

Jan 15th, 2022
721
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.company;
  2.  
  3. import java.util.Arrays;
  4. import java.util.Collections;
  5. import java.util.Scanner;
  6.  
  7. public class PrimeFactors {
  8.     public static void main(String[] args) {
  9.  
  10.         Scanner input = new Scanner(System.in);
  11.         int primeNumberObjectForCalculation = Integer.parseInt(input.nextLine());
  12.  
  13.         for (int i = 2; i <= primeNumberObjectForCalculation; i++) {
  14.  
  15.             while (primeNumberObjectForCalculation % i == 0) {
  16.                 primeNumberObjectForCalculation = primeNumberObjectForCalculation / i;
  17.                 System.out.println(i);
  18.             }
  19.         }
  20.     }
  21. }
  22.  
RAW Paste Data