质数因子
质数因子
http://www.nowcoder.com/questionTerminal/196534628ca6490ebce2e336b47b3607
import java.io.*; import java.util.*; public class Main{ public static void main(String[] args) throws Exception{ Scanner sc = new Scanner(System.in); while(sc.hasNextLong()){ long s = sc.nextLong(); for (int i = 2; i <= Math.sqrt(s); i++) { if (s % i == 0) { System.out.print(i + " "); s = s / i; // 还需要进行 i 判断, i -- 和 i++ 进行抵消,保证为 i i--; } } System.out.println(s + " "); } } }