分解质因数

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.

bash;gutter:true;
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

分解质因数

作者:九命猫幺
博客出处:http://www.cnblogs.com/yongestcat/
欢迎转载,转载请标明出处。
如果你觉得本文还不错,对你的学习带来了些许帮助,请帮忙点击右下角的推荐

Original: https://www.cnblogs.com/yongestcat/p/13437658.html
Author: 九命猫幺
Title: 分解质因数

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/565628/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球