Skip to content

Instantly share code, notes, and snippets.

@pamelafox
Created August 30, 2021 06:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pamelafox/6fed2476f145c9bf82febe1836b09c9e to your computer and use it in GitHub Desktop.
Save pamelafox/6fed2476f145c9bf82febe1836b09c9e to your computer and use it in GitHub Desktop.
Sum Multiples
""""
Write a function that sums up the multiples of a given number between a given start and end.
If the start or end numbers are also multiples, it should include them in the sum.
For example, if the range is 1-12 and the divisor is 4, the function should add 4+8+12, returning 24.
"""
def sum_multiples(start, end, divisor):
"""
>>> sum_multiples(1, 12, 4)
24
>>> sum_multiples(1, 12, 13)
0
>>> sum_multiples(2, 2, 2)
2
>>> sum_multiples(2, 2, 3)
0
>>> sum_multiples(23, 81, 13)
260
"""
# YOUR CODE HERE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment