Skip to content
Onsite

Count Multiples of K in a Range

EasyP3Coding

Return how many integers in the inclusive range [left, right] are divisible by k.

Example 1

Input
left = 1, right = 10, k = 3
Output
3
Why
3, 6, 9 are the multiples.

Example 2

Input
left = 5, right = 5, k = 5
Output
1

Example 3

Input
left = 6, right = 6, k = 5
Output
0

Constraints

  • 1 <= left <= right <= 10^9
  • 1 <= k <= 10^9

Hints

Run checks the 3 visible tests, Submit all 8.