Recall & Review
beginner
What is modular arithmetic?
Modular arithmetic is a system of arithmetic for integers where numbers wrap around after reaching a certain value called the modulus.
Click to reveal answer
beginner
What does the expression 'a % m' mean in modular arithmetic?
It means the remainder when integer 'a' is divided by the modulus 'm'. This remainder is always between 0 and m-1.
Click to reveal answer
beginner
How do you add two numbers under modulus m?
Add the two numbers normally, then take the remainder when divided by m: (a + b) % m.
Click to reveal answer
beginner
What is the result of (a * b) % m?
Multiply a and b normally, then take the remainder when divided by m: (a * b) % m.
Click to reveal answer
intermediate
Why is modular arithmetic useful in programming?
It helps keep numbers within a fixed range, prevents overflow, and is used in hashing, cryptography, and cyclic structures.
Click to reveal answer
What is the value of 17 % 5?
✗ Incorrect
17 divided by 5 is 3 with remainder 2, so 17 % 5 = 2.
Which of these is true for modular addition?
✗ Incorrect
Modular addition distributes over modulus: (a + b) % m = ((a % m) + (b % m)) % m.
What is (4 * 6) % 5?
✗ Incorrect
4 * 6 = 24, 24 % 5 = 4, since 24 divided by 5 is 4 with remainder 4.
If a % m = 3 and b % m = 4, what is (a + b) % m?
✗ Incorrect
The sum modulo m is (3 + 4) % m. Without knowing m, we cannot simplify further.
Which of these is NOT a use of modular arithmetic?
✗ Incorrect
Sorting arrays does not typically use modular arithmetic.
Explain how modular addition works and why it is useful.
Think about adding two numbers and then wrapping around a fixed number.
You got /3 concepts.
Describe a real-life example where modular arithmetic is used.
Consider how hours reset after 12 or 24.
You got /3 concepts.
