歐拉計劃-5

在這裏插入圖片描述

end = 20
temp = [num for num in range(2,end+1)]
n = len(temp)
for index_1 in range(n):
    num = temp[index_1]  # 將其作爲被除數
    for index_2 in range(index_1+1,n):
        if temp[index_2]%num == 0 and num != 1:
            temp[index_2] /= num

s = 1
for num in temp:
    s *= num
print(s)

反正問題是解決了,以後看看有沒有簡潔的方法。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章