Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Third solution in Clear category for Count Divisibles in Range (simplified) by freeman_lex
def count_divisible(n: int, k: int) -> int:
return len(range(k, n+1, k))
print("Example:")
print(count_divisible(2, 1))
# These "asserts" are used for self-checking
assert count_divisible(10, 2) == 5
assert count_divisible(10, 3) == 3
assert count_divisible(10, 5) == 2
assert count_divisible(15, 4) == 3
assert count_divisible(20, 6) == 3
assert count_divisible(100, 10) == 10
assert count_divisible(200, 25) == 8
assert count_divisible(50, 7) == 7
assert count_divisible(60, 8) == 7
assert count_divisible(70, 9) == 7
print("The mission is done! Click 'Check Solution' to earn rewards!")
Sept. 26, 2023
Comments: