题解 | #质数因子#
质数因子
http://www.nowcoder.com/practice/196534628ca6490ebce2e336b47b3607
import java.util.*;//不知道此处直接使用 .* 来加载包好不好?
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
long num = sc.nextLong();
for(int i = 2 ; i <= Math.sqrt(num) ; i++){
while(num % i == 0){
System.out.print(i + " ");
num /= i;
}
}
System.out.println(num == 1 ? "" : num + " ");
}
}
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
long num = sc.nextLong();
for(int i = 2 ; i <= Math.sqrt(num) ; i++){
while(num % i == 0){
System.out.print(i + " ");
num /= i;
}
}
System.out.println(num == 1 ? "" : num + " ");
}
}