代码:
辗转相除即可。
import java.util.*;
public class Main{
public static boolean judge(long value){
for(long i = 1;i<=value;i++){
if(value%i==0&&value!=i&&i!=1){
return false;
}
}
return true;
}
public String getResult(long uIDataInput){
String res = "";
while(uIDataInput!=1){
for(long i = 1;i<=uIDataInput;i++){
if(i!=1&&uIDataInput%i==0&&judge(i)){
res+=String.valueOf(i);
res+=" ";
uIDataInput/=i;
break;
}
}
}
return res;
}
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
long str = sc.nextLong();
System.out.print(new Main().getResult(str));
}
}
}