前几天发现了 projecteluer.net 网站,感觉里面的题目很有意思,便打算每天更新一篇博客,内容主要是 Project Euler Problem 的个人解答。其中解答内容仅代表个人观点,如果有错误或者异议,可以一起讨论,一起学习,谢谢。
Problem 1
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
# 求1000以内所有 3 和 5 的倍数的和。
L = [x for x in range(1,1000) if x%3==0 or x%5==0]
s = sum(L)
print(s)
结果:233168