Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
code that worked hard solution in Clear category for Count Divisibles in Range by tamagoyaki
def count_divisibles(start: int, end: int, n: int) -> int:
return (dif := end - start + 1)//n + 1*(end%n < dif%n or (start*-1)%n < dif%n)
print("Example:")
print(count_divisibles(1, 9, 3))
# These "asserts" are used for self-checking
assert count_divisibles(7, 28, 4) == 6
assert count_divisibles(-77, 19, 10) == 9
assert count_divisibles(1, 999999999999, 5) == 199999999999
print("The mission is done! Click 'Check Solution' to earn rewards!")
Nov. 6, 2023