Modulo Calculator
Calculate the remainder: a mod n
What Is Modulo?
The modulo operation finds the remainder after division. "a mod n" asks: when you divide a by n, what's left over? Example: 17 mod 5 = 2, because 17 = 5×3 + 2.
Enter the dividend (a)
This is the number being divided. Can be positive, negative, or decimal.
Enter the divisor (n)
This is the number you're dividing by. Cannot be zero.
Calculate the remainder
The result is always between 0 and the divisor (exclusive).
Modulo arithmetic is sometimes called "clock arithmetic." On a 12-hour clock, 15:00 is the same as 3:00 because 15 mod 12 = 3. The pattern repeats every 12 hours.
| Expression | Calculation | Result |
|---|---|---|
| 17 mod 5 | 17 = 5×3 + 2 | 2 |
| 20 mod 4 | 20 = 4×5 + 0 | 0 |
| 7 mod 3 | 7 = 3×2 + 1 | 1 |
| 100 mod 7 | 100 = 7×14 + 2 | 2 |
Cryptography
RSA encryption and many cryptographic algorithms rely on modular arithmetic with large prime numbers.
Computer Science
Hash functions, circular buffers, and determining even/odd (n mod 2) all use modulo operations.
Time Calculations
Converting between 24-hour and 12-hour time, calculating day of week, handling wraparound.
Checksums
ISBN check digits, credit card validation (Luhn algorithm), and error detection use modulo.
What does mod mean in math?
"Mod" is short for "modulo." It gives the remainder after division. 17 mod 5 = 2 means when you divide 17 by 5, the remainder is 2. Written as: 17 ≡ 2 (mod 5).
Can modulo handle negative numbers?
Yes, but conventions vary. This calculator uses the mathematical convention where the result is always non-negative. -7 mod 3 = 2, because -7 = 3×(-3) + 2.
What is modulo used for in programming?
Common uses include: checking if a number is even (n % 2 == 0), cycling through array indices, implementing hash tables, limiting values to a range, and creating repeating patterns.
How is modulo different from remainder?
For positive numbers, they're the same. For negative numbers, they can differ. The modulo result always has the same sign as the divisor. Remainder takes the sign of the dividend.
What happens if I divide by zero?
Modulo by zero is undefined, just like regular division. The calculator will not produce a result. Mathematically, there's no meaningful answer to "a mod 0."
Other Free Tools
Division Calculator
Division Calculator
Addition Calculator
Addition Calculator
Multiplication Calculator
Multiplication Calculator
Subtraction Calculator
Subtraction Calculator – Subtract Numbers Instantly
Expression Evaluator
Expression Evaluator
Percentage Calculator
Percentage Calculator – Calculate Percentages Instantly