Modulo Calculator
Calculate the modulo (remainder) of any two integers: a mod n = r.
Shows quotient, remainder, step-by-step division, and clock arithmetic examples.
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
That split catches people out constantly. C, Java, JavaScript, Go and Rust all give −1 for -7 % 3, because they truncate the quotient toward zero. Python, Ruby and most mathematics give 2, because they round the quotient downward. Neither is a bug; they answer slightly different questions, and both satisfy the identity a = b × quotient + remainder with their own quotient. The results below show you both, so you can see which one your language will hand you.
Why the remainder is always smaller than the divisor
If the remainder were as large as the divisor, you could fit one more copy of the divisor into the dividend, and the quotient would be one higher. So the remainder of a mod b always sits between 0 and b − 1. That is why n mod 12 on a clock can only ever return 0 through 11, and why the sawtooth in the chart drops back to zero the moment it reaches the divisor.
A quick divisibility trick worth knowing A number is divisible by 3 when the sum of its digits is divisible by 3, and by 9 when the digit sum is divisible by 9. Both work because 10 mod 9 = 1, so every power of ten leaves a remainder of 1 and each digit simply contributes itself. The same idea gives the divisibility test for 11, using alternating signs, since 10 mod 11 = −1.
How we build and check this calculator
This calculator runs entirely in your browser, so the numbers you enter stay on your device. The math behind it is written by hand and tested against worked examples and standard references before the page goes live.
SuperGlobalCalculator is independently built and maintained. See how we build and verify our calculators.
More Math Calculators
- Percentage Calculator
- Percentage Change Calculator
- Permutation & Combination Calculator
- Prime Number Checker
- Probability Calculator
- Proportions Solver
- Quadratic Formula Calculator
- Ratio Calculator
- Real-World Combinations Calculator
- Roman Numeral Converter
- Rule of Three Calculator
- Scientific Notation Converter