分解质因数

pyschools Topic 5: Question 12题目:分解质因素

Given a positive integer, write a function that computes the prime factors that can be multplied together to get back the same integer.

def primeFactorization(num): 
    factor=[]
    while num>1:
        for i in range(2,num+1):
            if num%i==0:
                factor.append(i)
                num = num//i
                break
    return factor

image

原文地址:https://www.cnblogs.com/yongestcat/p/13437658.html