热线电话:13121318867

登录
2019-03-28 阅读量: 757
题目:将一个正整数分解质因数。

程序分析:

# 代码
def reduceNum(n):
print("%d = "%n,end="")
while n not in [1] :
for index in range(2, n + 1) :
while n % index == 0:
n /= index
if n == 1:
print (index)
else :
print ("%d * "%index,end="")
reduceNum(90)
reduceNum(100)
# 输出
90 = 2 * 3 * 3 * 5
100 = 2 * 2 * 5 * 5
0.0000
0
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子