Modulo Calculator
The Remainder After Division ⚡
Calculate a mod b — the remainder when a is divided by b. Essential for programming, cryptography, and number theory.
Calculate a mod b — the remainder when a is divided by b. Essential for programming, cryptography, and number theory.
The modulo operation (written as a mod b, or a % b in most programming languages) finds the remainder left over after dividing one number by another as many whole times as possible. For example, 17 mod 5 = 2, because 17 ÷ 5 = 3 remainder 2.
The result is always between 0 and (b−1). If the dividend is exactly divisible by the divisor, the result is 0.
a mod b = a − (b × floor(a ÷ b))
Example: 17 mod 5 → 17 ÷ 5 = 3.4 → floor = 3 → 3 × 5 = 15 → 17 − 15 = 2
What is 0 mod n?
Always 0. Zero divided by any non-zero number leaves no remainder.
What is n mod n?
Always 0. Any number divided by itself goes exactly once with no remainder.
What is n mod 1?
Always 0. Every integer is divisible by 1 with no remainder.
What is the difference between mod and remainder?
For positive numbers they are identical. For negative numbers, different programming languages handle this differently. Python's modulo always returns a non-negative result (same sign as b), while JavaScript's % operator returns a result with the same sign as a. This calculator uses the mathematical convention where the result is always non-negative.
How is modulo used in cryptography?
Modular arithmetic forms the foundation of public-key cryptography. RSA encryption uses modular exponentiation with numbers hundreds of digits long. The security relies on the fact that multiplying primes together is easy, but factoring the result back into primes is computationally infeasible for large numbers.
What does it mean if the result is 0?
A result of 0 means a is exactly divisible by b — there is no remainder. For example, 15 mod 3 = 0 because 15 ÷ 3 = 5 exactly.