题解 | #质数因子#
质数因子
https://www.nowcoder.com/practice/196534628ca6490ebce2e336b47b3607
import math def isOdd (n) : if (n <= 0 or n == 1) : return False elif (n == 2) : return True else : for i in range((int)(math.sqrt(n)) + 1) : if (i > 1 and n % i == 0) : return False return True n = int(input()) if (isOdd(n)) : print(n) else : end = (int)(math.sqrt(n)) + 1 re = [] for i in range(end) : if (isOdd(i)) : while(n % i == 0): re.append(i) n = n // i if (isOdd(n)) : re.append(n) break for a in re : print(a, end = ' ')