TFT

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.

How to Use This Modulo Calculator
1

Enter the dividend (a)

This is the number being divided. Can be positive, negative, or decimal.

2

Enter the divisor (n)

This is the number you're dividing by. Cannot be zero.

3

Calculate the remainder

The result is always between 0 and the divisor (exclusive).

Understanding Modulo Operations

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.

ExpressionCalculationResult
17 mod 517 = 5×3 + 22
20 mod 420 = 4×5 + 00
7 mod 37 = 3×2 + 11
100 mod 7100 = 7×14 + 22
Formula: a mod n = a - n × floor(a/n)
Common Applications of Modulo

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.

Frequently Asked Questions

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."