Complete the code to compute the remainder of division.
int remainder = 17 [1] 5;
The % operator gives the remainder when 17 is divided by 5, which is 2.
Complete the code to add two numbers and get the result modulo 10.
int result = (7 + 8) [1] 10;
The % operator returns the remainder after division by 10, so (7 + 8) % 10 = 15 % 10 = 5.
Fix the error in the code to correctly compute (a * b) modulo m.
int modProduct = (a [1] b) % m;To compute the product modulo m, multiply a and b using * then take modulo m.
Fill both blanks to compute (x - y) modulo n correctly.
int modDiff = (x [1] y + n) [2] n;
Subtract y from x, add n to avoid negative results, then take modulo n.
Fill both blanks to create a map of numbers to their modulo 4 values for 1 to 5.
Map<Integer, Integer> modMap = new HashMap<>(); for (int i = 1; i <= 5; i++) { modMap.put(i, i [1] [2]); }
Use i as key (no change), compute i % 4 as value.
