← all problems

countMultiplesInRange 🌶️🌶️

Paydays come every d days, on day numbers that are multiples of d (including day 0). Write a method countMultiplesInRange that takes low, high and a positive d and returns how many whole numbers from low to high, including both, are multiples of d. If low is greater than high there are none.

For example, countMultiplesInRange(1, 30, 7) is 4 (7, 14, 21 and 28), and countMultiplesInRange(0, 10, 5) is 3.