Files
python/sum-of-multiples/example.py

14 lines
345 B
Python
Raw Normal View History

2014-03-18 04:30:26 +01:00
class SumOfMultiples(object):
def __init__(self, *args):
2014-10-25 23:28:24 +02:00
self.numbers = args or (3, 5)
2014-03-18 04:30:26 +01:00
def to(self, limit):
return sum(n
for n in range(limit)
if self.is_multiple(n))
def is_multiple(self, m):
2014-10-25 23:28:24 +02:00
return any(n != 0 and m % n == 0
2014-03-18 04:30:26 +01:00
for n in self.numbers)