← Unit 2 · all exercises
Saved in this browser only

Count the multiples

Count how many numbers from 1 up to and including the limit divide evenly by the given divisor.

int countMultiples(int limit, int divisor)

Solution.java
Loading editor…
Results

Examples

  • countMultiples(10, 2) → 5
  • countMultiples(10, 3) → 3

There are also 4 hidden tests you can't see. Solve the problem, not the examples.