Modulo Calculator
Calculate the modulo (remainder) of a division.
Shows quotient, remainder, and a clock arithmetic example.
Modulo Result
Modulo (mod) returns the remainder after dividing one number by another.
a mod b = a − b × floor(a / b)
Or equivalently:
a = b × quotient + remainder
Examples:
17 mod 5 = 2(17 = 5 × 3 + 2)25 mod 7 = 4(25 = 7 × 3 + 4)100 mod 10 = 0(100 = 10 × 10 + 0)7 mod 3 = 1(7 = 3 × 2 + 1)
Clock arithmetic (mod 12):
- If it is 10 o’clock and you add 5 hours: (10 + 5) mod 12 = 3 o’clock
- If it is 7 o’clock and you add 20 hours: (7 + 20) mod 12 = 3 o’clock
Common uses:
- Even/odd check:
n mod 2→ 0 = even, 1 = odd - Cycling/wrapping: array indices, day of week
- Digit extraction:
n mod 10gives the last digit - Divisibility test:
n mod d = 0means n is divisible by d - Cryptography: RSA encryption uses modular exponentiation
Negative numbers:
- In mathematics:
−7 mod 3 = 2(remainder is always non-negative) - In some programming languages:
−7 % 3 = −1(sign matches dividend) - This calculator uses the mathematical definition