解题步骤:

  1. 判断质数

  2. 因式分解(辗转相除)

  3. 判断商数是否为1

    import java.util.Scanner;
    public class test {
     public static void main(String args[]) {
         Scanner scanner = new Scanner(System.in);
         long num=scanner.nextLong();
         long temp=num;
         for(long i=2;i<=Math.sqrt(num);i++){
             if(isP(i)){
                 while (temp%i==0){
                     System.out.print(i);
                     System.out.print(' ');
                     temp=temp/i;
                 }
             }
    
         }
         //判断商是否为1
         if(temp>1){
             System.out.print(temp);
             System.out.print(' ');
         }
     }
     //判断是否为质数
     public static boolean isP(long n){
         if (n <= 1) return false;
         for(long i = 2; i * i <= n; ++i)
             if (n % i == 0) return false;
         return true;
     }
    }
    

```