Created
October 19, 2020 01:00
-
-
Save mcvarer/8f2000f67271e3e4a3c7a0eb8c348122 to your computer and use it in GitHub Desktop.
projecteuler:1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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. | |
""" | |
def calcMultipleSum(number: int, n: int, m: int) -> int: | |
ret = [] | |
for i in range(1, number): | |
if i % n == 0 or i % m == 0: | |
ret.append(i) | |
return sum(ret) | |
print("Sum of all the multiples = {}".format(calcMultipleSum(1000, 3, 5))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment