质数因子——java题解
质数因子
http://www.nowcoder.com/questionTerminal/196534628ca6490ebce2e336b47b3607
import java.util.Scanner; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); while(sc.hasNext()){ long n = sc.nextLong(); for(int i = 2; i < n; i++){ if(n % i == 0){ System.out.print(i + " "); n = n / i; //i = 2不行,因为出了这次循环会执行i++ i = 1; } } System.out.print(n + " "); } } }