Python 练习实例14
2017-11-18 00:49
411 查看
题目:将一个正整数分解质因数。例如:输入90,打印出90=2*3*3*5。程序
import math def pj(k): for i in range(2,int(math.sqrt(k))+1): if(k%i == 0): return False return True def MaxH(k): for i in range(2,int(k/2)+1): if(k%i == 0): return i list = [] n = int(input("请输出一个整数:")) list.append(n) i = 0 while(i<len(list)): if(not pj(list[i])): list.append(int(MaxH(list[i]))) list.append(int(list[i]/list[-1])) list.remove(list[i]) i = 0 else: i += 1 print(list)
分析
相关文章推荐
- Python 练习实例14
- python练习实例14,题目:将一个正整数分解质因数。例如:输入90,打印出90=2*3*3*5。
- Python 练习实例14
- Python 练习实例14
- Python练习实例14
- Python 练习实例25
- Python 练习实例18
- Python 练习14---if...in
- Python实例练习4
- Python练习实例6
- Python练习实例24
- Python 练习实例31
- Python 练习实例15
- Python 练习实例5
- Python初学时购物车程序练习实例(推荐)
- python_笔记14_创建类的实例(支持多属性),方法也是属性
- Python 练习实例4
- Python 练习实例13
- Python 练习实例15
- Python 练习实例12