欧拉计划-第3,6题

中文网:https://pe-cn.github.io/
原网址:https://projecteuler.net/
算法弱鸡。Hahaha。

前两天出去玩了,今天多写两个好了。
3.
在这里插入图片描述

ans = []
n = 600851475143
iter_max = int(n ** 0.5)
for num in range(2,iter_max):
    if n%num == 0:
        ans.append(num)
        n/=num
        while n%num == 0:
            n/=num
print(ans)

最终答案:
[71, 839, 1471, 6857]
取6857
在这里插入图片描述
You are the 468525th person to have solved this problem…

在这里插入图片描述

s1 = 0 
k1 = 0
for num in range(101):
    s1 += num
    k1 += num**2
s1 **= 2
s1-k1

numpy写的话,比较节约。

a = np.linspace(1,100,100)
k = np.sum(a)**2 - np.sum(a*a)

25164150

在这里插入图片描述
425385了。

5.这次是1-20的最小公倍数
在这里插入图片描述

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