码迷,mamicode.com
首页 > 其他好文 > 详细

projecteuler(欧拉几何)问题的一些归档。

时间:2015-05-06 11:16:37      阅读:139      评论:0      收藏:0      [点我收藏+]

标签:python projecteuler

练习自己的code能力,完成projecteuler的题目,做一个归档记录。


第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的数,并计算出它们的和。

def Multiples_of_3_and_5(num):
    sum = 0
    for n in xrange(num):
        if not n%3 or not n%5:
            sum+=n
    return sum

if __name__ == "__main__":
    print Multiples_of_3_and_5(1000)


projecteuler(欧拉几何)问题的一些归档。

标签:python projecteuler

原文地址:http://python386.blog.51cto.com/8426035/1642327

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!