#45254: python 解答


brian1001115@gmail.com (brian chen)

學校 : 不指定學校
編號 : 293445
來源 : [122.118.27.58]
最後登入時間 :
2024-11-17 16:11:27
a010. 因數分解 | From: [122.118.8.250] | 發表日期 : 2025-02-02 15:16

a = int(input())
factors= []
i = 2
while a != 1:
    j = 0
    while a % i == 0:
        j += 1
        a  //= i
    if j > 0:
        if j == 1:
            factors.append(str(i))
        else:
            factors.append(f"{i}^{j}")
    i += 1

print(" * ".join(factors))

 
ZeroJudge Forum