What is modulo?
Modulo is the operation that tells you what remains after one integer is divided by another. If a = qn + r, then a mod n = r under the Euclidean convention used by this calculator.
Modulo formulas and the division identity
The most useful way to understand modulo is to keep the complete division equation visible. The remainder is not an isolated number; it is the part left after complete groups have been removed.
Find the remainder
Compute q = floor(a / |n|), then calculate r = a − q|n|. The result r is the Euclidean remainder.
Check the answer
Rebuild the dividend: q|n| + r must equal a. This identity is the fastest way to catch an arithmetic mistake.
Modulo and congruence
Two integers a and b are congruent modulo n when their difference is divisible by n. This is written a ≡ b (mod n). Equivalently, they have the same remainder when divided by n.
Modulo examples, step by step
The same three-step pattern works for small remainders, large dividends, and clock-style cycles: divide, keep the complete groups, then read the remainder.
17 mod 5
250 mod 24
1 mod 10
100 mod 7
Common modulo values
Quick reference| Expression | Quotient | Remainder | Check |
|---|---|---|---|
| 1 mod 1 | 1 | 0 | 1 = 1×1 + 0 |
| 5 mod 2 | 2 | 1 | 5 = 2×2 + 1 |
| 5 mod 3 | 1 | 2 | 5 = 1×3 + 2 |
| 6 mod 3 | 2 | 0 | 6 = 2×3 + 0 |
| 10 mod 3 | 3 | 1 | 10 = 3×3 + 1 |
| 17 mod 3 | 5 | 2 | 17 = 5×3 + 2 |
| 100 mod 7 | 14 | 2 | 100 = 14×7 + 2 |
| 250 mod 24 | 10 | 10 | 250 = 10×24 + 10 |
How modulo behaves in arithmetic
Modulo lets arithmetic wrap around a fixed cycle. You can reduce numbers before adding or multiplying, which is especially useful when the original numbers are large.
Why this matters
These identities make it possible to keep intermediate numbers small. Modular arithmetic is therefore useful in algorithms, checksums, scheduling, repeating patterns, and cryptography.
Why negative modulo results can differ
Negative values are where mathematical modulo and programming-language remainder operators can appear to disagree. The underlying division identity is the same, but the chosen quotient convention can change the representative remainder.
Euclidean convention
For a positive modulus, choose a non-negative remainder. For example, −9 = (−3) × 4 + 3, so the Euclidean remainder is 3.
JavaScript %
JavaScript's remainder operator keeps the sign of the dividend. Therefore −9 % 4 is −1. This calculator shows that value separately from the Euclidean result.
Where modulo is used
Modulo is a simple operation with a surprisingly broad role. Whenever a quantity repeats in a fixed cycle or you need to test divisibility, modulo is often the right tool.
Application map
Concept → practical use| Application | Modulo idea | Example |
|---|---|---|
| Clock arithmetic | Wrap around a fixed cycle | 15 mod 12 = 3 |
| Divisibility tests | Check whether r = 0 | 496 mod 4 = 0 |
| Repeating schedules | Map a count to a cycle position | day mod 7 |
| Checksums | Reduce a running total | digit-based checks |
| Algorithms | Keep values inside a bounded range | index mod length |
| Cryptography | Arithmetic over finite cycles | modular exponentiation |