Modulo Calculator
The modulo operation finds the remainder after dividing one number by another. Expressed as a mod b or a % b, it answers: what is left over after dividing a by b as many times as possible? For example, 17 mod 5 = 2 because 17 divided by 5 equals 3 with a remainder of 2. The division algorithm shows this as: a = b × quotient + remainder. This calculator computes the modulo, quotient, and displays the division equation. Modulo is essential in programming, cryptography, and mathematics for checking divisibility, cycling through sequences, and many algorithmic applications.
Modulo formula
a mod b = remainder of (a / b)
a = b × quotient + remainder
Example: 17 mod 5: quotient = floor(17/5) = 3, remainder = 17 - (5 × 3) = 2
Modulo examples
| a | b | a mod b | Quotient | Equation |
|---|---|---|---|---|
| 17 | 5 | 2 | 3 | 17 = 5 × 3 + 2 |
| 20 | 3 | 2 | 6 | 20 = 3 × 6 + 2 |
| 10 | 2 | 0 | 5 | 10 = 2 × 5 + 0 |
| 15 | 7 | 1 | 2 | 15 = 7 × 2 + 1 |
Modulo calculator: frequently asked questions
What is the modulo operation?
The modulo operation finds the remainder after division. It is written as a mod b or a % b. For example, 17 mod 5 = 2 because 17 divided by 5 equals 3 with a remainder of 2 (17 = 5 × 3 + 2).
How do you calculate modulo?
To calculate a mod b: divide a by b, find the quotient (ignoring remainder), multiply the quotient by b, and subtract from a. Example: 17 mod 5: quotient = 3, 3 × 5 = 15, 17 - 15 = 2.
What does the equation a = b × q + r mean?
This is the division algorithm. a is the dividend, b is the divisor, q is the quotient, and r is the remainder. For 17 = 5 × 3 + 2: 17 is a, 5 is b, 3 is q, and 2 is r (the modulo result).
How do negative numbers work with modulo?
Modulo with negative numbers depends on the language. In JavaScript, -17 mod 5 = -2 (the remainder takes the sign of the dividend). Different languages handle this differently. This calculator uses JavaScript's convention.
What are practical uses of modulo?
Modulo is used for: checking if a number is even (n mod 2), cycling through arrays, distributing items into groups, generating patterns, checking divisibility, and creating hash functions.
Official sources
- Modulo operation: NIST Special Publication 330.
Reviewed by the CalculatorHub team, edited by James Graham, 14 June 2026. See our methodology.