Learn AP Comp Sci

☰

Problem of the Day

Thursday, November 12, 2026


Problem:

Consider the following method.

public static helper(int m, int n)
{
while (m > n)
{
m -= n;
}
return m;
}
}

Which of the following operations does the method helper implement?

  1. calculating a power, mn
  2. integer division, m / n
  3. integer division, m % n
  4. integer multiplication, m * n

Show solution:

The correct answer is c. The dividend, represented by m, has the divisor n subtracted from it until m is less than n, at which point no additional subtractions can be performed without producing a negative result. The remaining value of m is... the "remainder," the result produced by the modulo, or mod or % operation in integer division.