import mathtry:while 1:n = int(input())box2=0a = ""b = ""c = 0
for i in range(2,n-1):if n <2:breakwhile n%i==0:n=n/ibox1 = ibox2 += 1
if box2 ==1:if c>=1:b = " * " +str(box1)else:b = str(box1)else:if c>=1:b = " * "+ str(box1)+"^"+str(box2)else:b = str(box1)+"^"+str(box2)if b !="":c+=1a+=str(b)b = ""box2 = 0if a == "":print(n)else:print(a)except EOFError:pass抱歉 剛發現把break判斷改成 if n <2 就可以了