题解 | #质数因子#
质数因子
http://www.nowcoder.com/practice/196534628ca6490ebce2e336b47b3607
import java.util.Scanner; public class Main{ public static void main(String[] args) { Scanner scanner = new Scanner(System.in); long numInit = scanner.nextLong(); long num=numInit; long k=(long)Math.sqrt(num); for(int i=2;i<k+1;i=i+1){ while(num%i==0){ System.out.print(i+" "); num=num/i; } } if(num!=1){ System.out.print(num+" "); } } }