题解 | #HJ6 质数因子#
质数因子
https://www.nowcoder.com/practice/196534628ca6490ebce2e336b47b3607
def prime_factors(n): factor = 2 factors = [] while factor ** 2 <= n: if n % factor == 0: factors.append(factor) n //= factor else: factor += 1 if n > 1: factors.append(n) return factors n = int(input()) print(" ".join(map(str, prime_factors(n))))
【牛客站内】华为机试题解 文章被收录于专栏
【牛客站内】 分享个人刷题的思路和解法