← Unit 1 · all exercises
Saved in this browser only

What is left over

Return the remainder when the first number is divided by the second. Java writes this with the % operator.

int remainder(int a, int b)

Solution.java
Loading editor…
Results

Examples

  • remainder(7, 2) → 1
  • remainder(10, 5) → 0

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