引用
题目: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.
我的python解:
num_3 = 999 / 3
num_5 = 999 / 5
num_15 = 999 / 15
num = 0
for i in range(num_3):
num += (i+1) * 3
for j in range(num_5):
num += (j+1) * 5
for x in range(num_15):
num -= (x+1) * 15
print num
如果有更好的的解法,求交流~
分享到:
相关推荐
NULL 博文链接:https://lampeter123.iteye.com/blog/423036
ProjectEuler题1-16题代码,直接引入Eclipse就可以用
NULL 博文链接:https://lifethinker.iteye.com/blog/290159
project euler代码库1,已测试通过
NULL 博文链接:https://linuke.iteye.com/blog/1056283
Project-Euler 来自projecteuler.net的练习题 其他信息和链接:
solution to problem 5
Project Euler solutions in assembler.
欧拉计划projecteuler.net
project euler代码库第二部分(已测试通过
project euler代码库第三部分(已测试通过
project euler代码库第五部分(已测试通过
projecteuler.net 我对 Project Euler 问题的一些解决方案: :
项目欧拉解决方案该存储库包含我对 Project Euler (projecteuler.net) 上发现的编程问题的所有答案。 每个解决方案都是用 Java 编写的,旨在从命令行运行。 解决方案文件中将提供指向相关欧拉问题的链接。 某些解决...
在线编程练习网站Euler project的前14题答案
project-euler:多种语言的projecteuler.net问题解决方案
Algorithm-hacktoberfest-projecteuler.zip,此repo包含多种语言的projecteuler问题的解决方案。为新来者特别设计,作为黑客节挑战的一部分。,算法是为计算机程序高效、彻底地完成任务而创建的一组详细的准则。
ProjectEulerQuestions projecteuler.net 上问题的解决方案
project_euler Project Euler 问题的解决方案 ###Problem 1 - 3 和 5 的倍数### 如果我们列出所有 10 以下是 3 或 5 的倍数的自然数,我们得到 3、5、6 和 9。这些倍数的和是 23。求1000 以下所有 3 或 5 的倍数之...
全部在linux下运行通过并得到结果,因为是个人所做,所以不保证是最优结果,仅供交流学习 因为是个人联系所做,所以代码中没有注释,不过我相信只要你真的有去思考题目也是能知道我为什么这样做 ...