Automatic commit performed through alias...

This commit is contained in:
Shaun Setlock
2020-08-02 07:38:10 -04:00
parent 675a507520
commit b7bfa36d06
11 changed files with 67 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
#!/usr/bin/env python
# Problem 1:
#
# 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.
import decorators
def check_divisibility(num, dict_multiples: dict) -> bool:
dummy = 1
for m in dict_multiples:
dummy *= num%m
if dummy == 0:
return True
else:
return False
@decorators.function_timer
def main():
multiples = {3,5}
sumval = 0
for n in range(1000):
r = check_divisibility(n,multiples)
if r:
sumval += n
print(sumval)
main()