Skip to content

Instantly share code, notes, and snippets.

@mcvarer
Created October 19, 2020 01:00
Show Gist options
  • Save mcvarer/8f2000f67271e3e4a3c7a0eb8c348122 to your computer and use it in GitHub Desktop.
Save mcvarer/8f2000f67271e3e4a3c7a0eb8c348122 to your computer and use it in GitHub Desktop.
projecteuler: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.
"""
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