Modulo Calculator
Calculate the remainder of division (modulo operation). Modulo calculator with explanations for modular arithmetic.
Calculator inputs
Inputs
The number being divided.
The number you're dividing by (cannot be 0).
Your results
Methodology
- Formula:
- Euclidean remainder
- Content last updated:
- Scheduled re-verification:
- August 2027
Calculation type: Exact calculation.
How to Use This Calculator
- Enter Numbers
Input the dividend (a) and divisor (b).
- See Remainder
The modulo operation returns the remainder after division.
Example: 17 mod 5
Find the remainder when 17 is divided by 5.
- Dividend (a)
- 17
- Divisor (b)
- 5
- Remainder (a mod b)
- 2
- Quotient
- 3
Understanding Your Results
- What is Modulo?a mod b returns the remainder when a is divided by b. Example: 17 mod 5 = 2 because 17 = 3 × 5 + 2. The remainder is always non-negative when the divisor is positive. In programming, % is the modulo operator: 17 % 5 = 2.
- Uses of ModuloModular arithmetic is used in: clock math (14:00 mod 12 = 2 PM), check-digit algorithms (ISBN, credit card numbers), cryptography (RSA encryption), hash functions, cyclic patterns, and determining even/odd (n mod 2 = 0 means even).
Key Tips
- If a mod b = 0, then a is divisible by b.
- n mod 2 tells you if a number is even (0) or odd (1).
- For negative numbers: -7 mod 5 = 3 (the result is always non-negative).
Understanding Modular Arithmetic
What Is Modular Arithmetic?
Modular arithmetic is a system where numbers 'wrap around' after reaching a certain value — the modulus. Think of a 12-hour clock: 14:00 is 2 PM because 14 mod 12 = 2. This wrap-around behavior makes modular arithmetic essential for cryptography (RSA, Diffie-Hellman), hash functions, checksums (ISBN-10, credit card Luhn algorithm), and pseudo-random number generation.
Properties of Modulo
Key properties: (a + b) mod m = ((a mod m) + (b mod m)) mod m. (a × b) mod m = ((a mod m) × (b mod m)) mod m. These properties are crucial for efficient computation in cryptography where numbers can have hundreds of digits. The result a mod b is always in the range [0, b−1] for positive b.
How modulo works in practice
The modulo operation returns the remainder after division: 17 mod 5 = 2, because 17 = 3 × 5 + 2. A clock is a modulo-12 system, so 9 hours after 8 o'clock is (8 + 9) mod 12 = 5. Days of the week repeat every 7 days, so 100 days from Monday is 100 mod 7 = 2 days later, a Wednesday. Whenever something cycles, modulo describes the position in the cycle.
Negative numbers and programming
Languages disagree about the sign of the result when the dividend is negative. Mathematics usually defines the remainder as non-negative, so −7 mod 3 = 2, while many programming languages return −1 for the same expression. Check which convention you need before using the result in code. Modulo is also used for checking whether a number is even (n mod 2 = 0), for hashing, for check digits in identification numbers, and for wrapping array indexes.
Formula & methodology
Formula used
Euclidean remainder
r = ((a mod |b|) + |b|) mod |b|The remainder is always non-negative and smaller than the divisor's absolute value, whatever the signs of a and b.
Quotient
q = (a − r) ÷ bDerived from the remainder so that q × b + r equals a exactly for every combination of signs.
Variable definitions
| Symbol | Meaning | Unit |
|---|---|---|
| a | Dividend. the number being divided | number |
| b | Divisor. the number to divide by; cannot be zero | number |
Step-by-step calculation
- 1. Enter the dividend and divisorBoth may be negative.
- 2. Check the verification lineIt restates quotient × divisor + remainder so you can confirm the identity holds.
Limitations
- Uses the Euclidean convention, in which the remainder is never negative. JavaScript's own % operator does not: it gives −7 % 3 = −1 where this returns 2.
- Division by zero is undefined and is reported as an error.
- Operates on values held as double-precision numbers, so very large integers lose precision.
This page is educational. It applies the formula described above to the figures you enter and shows the arithmetic behind the result. The output is only as good as the inputs and the assumptions listed here, and it is general information rather than advice about your particular situation.
Frequently Asked Questions
What does modulo mean?
Modulo (a mod b) returns the remainder when a is divided by b. 17 mod 5 = 2 because 17 = 3 × 5 + 2. The result is always between 0 and b−1 for positive b.
What is modulo used for?
Modulo checks divisibility (even/odd), wraps numbers in ranges (clock arithmetic), powers checksums, cryptography (RSA), and cyclic operations in programming.
What happens with a negative dividend, like -7 mod 5?
This calculator always returns a non-negative remainder for a positive divisor: -7 mod 5 = 3, because -7 = -2 × 5 + 3. The quotient shown (-2) is the floor of -7/5, so quotient × divisor + remainder always equals the original dividend.
Can the divisor be zero?
No — division by zero is mathematically undefined, so the calculator returns an error instead of a result when the divisor is 0.
How is modulo different from regular division?
Regular division gives a quotient (how many times b fits into a) and possibly a decimal. Modulo gives only the leftover remainder as a whole number — the part that doesn't divide evenly.
Need more help? Contact support or email globalcalqulate@gmail.com. We typically reply within 24–48 hours.