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