【每日一题1028】三五成群

:mage:t2: 如果我们列出10以下的能够被3和5整除的自然数,就会得到3, 5, 6和9,并且总和是23。那么请根据这个规律,编写一个函数,接收一个正整数num,找出0到这个数(不包含)之间所有能被3或者5整除的数字之和。
备注:如果一个数字同时满足被两个数整除则只取一次,例如15。

示例:
输入:10,输出:23。因为3+5+6+9=23
输入:5, 输出:3。

题目难度:简单
题目来源:codewars: Multiples of 3 or 5

def cal_sum(num: int) -> int:
    pass

assert cal_sum(5) == 3
assert cal_sum(10) == 23
assert cal_sum(15) == 45
assert cal_sum(200) == 9168
def cal_sum(num: int) -> int:
    return sum([i for i in range(num) if i % 3 == 0 or i % 5 == 0])


assert cal_sum(5) == 3
assert cal_sum(10) == 23
assert cal_sum(15) == 45
assert cal_sum(200) == 9168
def cal_sum(num: int) -> int:
    return sum([i for i in range(num) if i%3 ==0 or i%5 ==0])

assert cal_sum(5) == 3
assert cal_sum(10) == 23
assert cal_sum(15) == 45
assert cal_sum(200) == 9168
def cal_sum(num: int) -> int:
    return sum([i for i in range(1,num) if i%3==0 or i%5==0])

assert cal_sum(5) == 3
assert cal_sum(10) == 23
assert cal_sum(15) == 45
assert cal_sum(200) == 9168
def cal_sum(num: int) -> int:
    return sum([i for i in range(0, num) if i % 3 == 0 or i % 5 == 0])


assert cal_sum(5) == 3
assert cal_sum(10) == 23
assert cal_sum(15) == 45
assert cal_sum(200) == 9168