[quote]题目: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.[/quote]
我的python解:
如果有更好的的解法,求交流~
Find the sum of all the multiples of 3 or 5 below 1000.[/quote]
我的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
如果有更好的的解法,求交流~