题解 | #质数因子#
质数因子
https://www.nowcoder.com/practice/196534628ca6490ebce2e336b47b3607
from math import sqrt
n = int(input())
N = n
results = []
i = 2
a, b = 1, 2
while True:
if n % i == 0:
results.append(i)
n = int(n / i)
a, b = n, i
else:
i += 1
if i > sqrt(N):
if n != 1:
results.append(n)
break
if len(results) > 0:
print(" ".join(map(str, results)))
else:
print(f'{N}')
查看4道真题和解析
OPPO公司福利 1077人发布