Created
August 30, 2021 06:35
-
-
Save pamelafox/0c15ef07a3eb2872cb2a57a69d94e154 to your computer and use it in GitHub Desktop.
Count 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 will count the amount of multiples | |
of a given divisor between a given start number and a given end number. | |
It should include the start or end if they are a multiple. | |
For example, if the range is 1 to 12 and the divisor is 3, | |
the function should return 4, since 3, 6, 9, and 12 can all be evenly divided by 3. | |
""" | |
def count_multiples(start, end, divisor): | |
""" | |
>>> count_multiples(2, 2, 1) # 2 is a multiple of 1 | |
1 | |
>>> count_multiples(2, 2, 2) # 2 is a multiple of 2 | |
1 | |
>>> count_multiples(2, 2, 3) # 2 is not a multiple of 3 | |
0 | |
>>> count_multiples(1, 12, 3) # 3, 6, 9, 12 | |
4 | |
>>> count_multiples(237, 500, 10) | |
27 | |
""" | |
# YOUR CODE HERE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment