Created
August 30, 2021 06:38
-
-
Save pamelafox/6fed2476f145c9bf82febe1836b09c9e to your computer and use it in GitHub Desktop.
Sum Multiples
This file contains hidden or 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
"""" | |
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