3和5的倍数相加和

method1:

def solu(num):

nums = list(range(1,10))
sum=0
for i in nums:
if i % 3 == 0 or i % 5 == 0:

sum += i
return sum
method2:
def solu(num):
  return sum(i for i in (list(range(1,num))) if i%3==0 or i%5==0)

posted on 2017-07-07 15:20  run_qin  阅读(206)  评论(0编辑  收藏  举报

导航