試題 算法提高 質因數
資源限制
時間限制:1.0s 內存限制:512.0MB
將一個正整數N(1<N<32768)分解質因數。例如,輸入90,打印出90=2335。
樣例輸入
66
樣例輸出
66=23*11
"""
@Author:Lixiang
@Blog(個人博客地址): https://lixiang007.top/
@WeChat:18845312866
"""
import math
import string
import sys
import cmath
from itertools import permutations
def fun(n,res):
for i in range(2,n+1):
if n %i==0:
res+=str(i)
n=n//i
if n==1:#短除到質數退出
return res
else:
res+='*'
return fun(n,res)
n=int(input())
res=""
temp=fun(n,res)
print(n,"=",temp,sep="")