今天第一次看到欧拉计划,感觉很兴奋,决定挑战一下。
什么是欧拉计划?
欧拉计划是一系列挑战数学、计算机编程的问题。
第一题:
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.Find the sum of all the multiples of 3 or 5 below 1000.
示例:
def divid(x):
return x % 3 == 0 or x % 5 ==0
sum = 0
for num in filter(divid, range(1,1000)):
sum += num
print(sum)
233168