首页 > 其他 > 详细

分解质因数

时间:2020-08-05 09:14:07      阅读:96      评论:0      收藏:0      [点我收藏+]

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

技术分享图片

分解质因数

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!