"""
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.
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.
my saying:
my solution can be changed easily,but I do not think it is a good answer,becase it compares more than it should be
"""
base=[3,5]
cur=2
maxnum=1000
result=[]
my solution can be changed easily,but I do not think it is a good answer,becase it compares more than it should be
"""
base=[3,5]
cur=2
maxnum=1000
result=[]
while cur<maxnum:
for i in base:
if cur/i==float(cur)/i:
result.append(cur)
break
cur+=1
for i in base:
if cur/i==float(cur)/i:
result.append(cur)
break
cur+=1
print result
print sum(result)
print sum(result)
没有评论:
发表评论