题解 | #质数因子#
质数因子
https://www.nowcoder.com/practice/196534628ca6490ebce2e336b47b3607
import java.util.Scanner;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
long a = in.nextLong();
long b = 2L;
// 判断是否质数 X^(1/2)
while(b<=Math.sqrt(a)) {
if(a%b==0) {
System.out.print(b+" ");
a = a/b;
} else{
b++;
}
}
System.out.print(a);
}
}
