euler/python/e001.py

12 lines
339 B
Python

def get_sum_of_natural_dividable_by_3_and_5_below(m):
return sum([x for x in range(m) if x % 3 == 0 or x % 5 == 0])
def euler_001():
return get_sum_of_natural_dividable_by_3_and_5_below(1000)
assert(get_sum_of_natural_dividable_by_3_and_5_below(10) == 23)
assert(euler_001() == 233168)
print("e001.py: {}".format(euler_001()))