中文網:https://pe-cn.github.io/
原網址:https://projecteuler.net/
算法弱雞。Hahaha。
要小心一點的是初始的是1,2,3,5,不是1,1,2,3。。。。還有就是,偶數求和不是對偶數的索引項,是索引對應的值,別問我爲什麼要小心。
list_num = [1,2]
num = 1
while num<=4000000:
num = list_num[-1] + list_num[-2]
list_num.append(num)
list_num.pop(-1)
_sum = 0
for num in range(len(list_num)):
if list_num[num]%2 == 0:
_sum += list_num[num]
print(_sum)
You are the 654545th person to have solved this problem…(留下了不學無術的眼淚…)