|
发表于 2018-7-23 17:48:25
|
显示全部楼层
本帖最后由 liujian973 于 2018-7-24 16:16 编辑
import math
temp_input=int(input("请输入分解的整数"))
temp=[]
for i in 2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,51,:
while temp_input % i ==0:
temp_input = temp_input / i
temp.append(i)
for i in range(53,int(math.sqrt(temp_input))+1,2):
if temp_input %i ==0:
temp_input /=i
temp.append(i)
temp.append(int(temp_input))
print(temp)
if len(temp) >=2:
temp_1, temp_2 = temp[-1], temp[-2]
for i in temp[:-2][::-1]:
print(i)
if temp_1 >= temp_2:
temp_2 *=i
else:temp_1 *=i
print(temp_1,temp_2) |
|