NC25066. [USACO 2007 Mar L]Prime Factors
描述
输入描述
Line 1: A single integer: N
输出描述
Line 1: All the prime factors of N, one per line, in ascending order
示例1
输入:
3423
输出:
3 7 163
说明:
This is the number to be broken down into its prime factors.Python3 解法, 执行用时: 43ms, 内存消耗: 4580K, 提交时间: 2023-08-15 09:55:57
N = int(input()) # 分解质因数 def getFactors(n): r = [] for k in range(2, int(n ** 0.5) + 1): while n != k: if n % k == 0: r.append(k) n /= k else: break r.append(int(n)) return r l = getFactors(N) for n in l: print(n)