Modulo Calculator: Find Any Remainder in Seconds
17 divided by 5 leaves 2 over. That leftover is the remainder, and it is what modulo finds. This modulo calculator finds that remainder in one step. You can use it whenever a division does not come out even and you need to know what is left.
This modulo calculator has five modes: Find the Remainder, Modulo with Negatives, Check Divisibility, Clock and Calendar, and Modulo of a List. Students also search for a mod calculator when they mean this same tool. Each mode handles a different kind of remainder problem, from a simple division to wrapping time around a clock. This page is the general remainder tool. The Percentage Calculator and the Exponent Calculator do not do this kind of remainder work, so use this page when you need a remainder, not a percentage or a power.
Modulo Calculator
Find any remainder, compare the two sign rules for negatives, check divisibility, and wrap clock time.
| Value | Remainder | Divisible |
|---|
Using the Modulo Calculator
The modulo calculator has five modes, each designed to solve a different kind of remainder problem.
Find the Remainder
Enter two numbers, and the tool divides the first by the second and returns the remainder. Here is how to calculate modulo in the first mode: divide, take the whole quotient, multiply back, and subtract. This modulus calculator returns the remainder and shows the check equation. For example, 17 mod 5 = 2, with a quotient of 3. The check is 17 = 5 × 3 + 2.
Modulo with Negatives
Enter a negative dividend or divisor, and the tool shows the floored and truncated answers side by side. That makes it easy to compare the two sign rules. For example, −17 mod 5 gives floored 3 and truncated −2.
Check Divisibility
Enter two numbers, and the tool says whether the first divides evenly into the second. It checks the remainder to decide. For example, 15 is divisible by 3, because the remainder is 0.
Clock and Calendar
Enter a start time and a number of hours, or a weekday and a number of days, and the tool wraps the answer around the clock or the week. For example, 9 o'clock + 5 hours = 2 o'clock.
Modulo of a List
Paste a list of numbers and one divisor, and the tool returns every remainder at once. For example, the list 17, 23, 100, 15 mod 5 gives remainders 2, 3, 0, 0.
Mode Comparison
| Mode | What you enter | What you get |
|---|---|---|
| Find the Remainder | Two numbers | The remainder after division |
| Modulo with Negatives | A negative dividend or divisor | The floored and truncated remainders |
| Check Divisibility | Two numbers | Whether the first divides evenly into the second |
| Clock and Calendar | A start time and hours, or a weekday and days | The time or weekday after wrapping around |
| Modulo of a List | A list of numbers and one divisor | Every remainder at once |
The following examples show the default result for each mode.
Worked Examples
| Mode | Example | Result |
|---|---|---|
| Find the Remainder | 17, 5 | 2 |
| Modulo with Negatives | −17, 5 | Floored 3, truncated −2 |
| Check Divisibility | 15, 3 | Divisible, remainder 0 |
| Clock and Calendar | 9 o'clock + 5 hours | 2 o'clock |
| Modulo of a List | 17, 23, 100, 15 mod 5 | Remainders 2, 3, 0, 0 |
About Modulo
Modulo is the remainder after division. It is written as a mod b, where a is the dividend and b is the divisor. The result fits the equation a = q × b + r, where q is the whole quotient and r is the remainder.
Working with powers of two under a modulus is how computers handle huge exponents without overflow, and the Exponent page teaches powers themselves.
A modulus finder does one job: it returns the remainder. The question of modulo vs remainder comes up often, and a modulo calculator settles it in one step: the modulo operation returns the remainder, and the remainder is the result.
The Rule
This section answers what is modulo, step by step.
A remainder follows one rule: a mod b = r, where a = b × q + r. Here, q is the whole number of times b fits into a, and r is what is left over. A modulus operator calculator follows this one rule for every input. The modulo calculator follows this one rule and shows the check equation with every answer.
- If the dividend is smaller than the divisor, the remainder is the dividend itself. For example, 7 mod 10 = 7, and 5/6 mod 76 = 5/6.
- 0 mod 5 = 0.
- A remainder by zero is undefined, so a mod 0 has no answer and the tool shows an error instead of NaN.
Modulo with Negative Numbers
The modulo calculator shows both answers side by side, so you can see why the sign rules matter.
Modulo of Negative Numbers
Take −17 mod 5 as an example. The floored answer is 3 (quotient −4), and the check is −17 = 5 × (−4) + 3. The truncated answer is −2 (quotient −3), and the check is −17 = 5 × (−3) + (−2). The floored remainder takes the sign of the divisor, and the truncated remainder takes the sign of the dividend. A modulo operator calculator shows both conventions side by side so you can compare them.
Here are more examples: −7 mod 3 = 2 floored and −1 truncated. 17 mod −5 = −3 floored and 2 truncated. −17 mod −5 = −2 floored and truncated, and 3 Euclidean.
The result also depends on the language you use. JavaScript's % is truncated, so −7 % 3 = −1. Python's % is floored, so −7 % 3 = 2. Excel's MOD is floored and takes the sign of the divisor: MOD(−340, 60) = 20, and MOD(10, −3) = −2.
For clock and congruence work, use the floored answer when the divisor is positive, since it is always 0 or more. That answer is the least non-negative residue.
Modulo of Decimals and Big Numbers
This modulo calculator computes decimal remainders exactly, from the typed digits, not from a binary float.
People who search for a calculator modular mean this same tool with decimal inputs.
Here are four decimal examples: 7.5 mod 2.5 = 0. 8.7 mod 2.5 = 1.2. 10.5 mod 3 = 1.5. 5.5 mod 2.0 = 1.5.
Why Computer Remainders Can Differ
The problem is the way computers store decimals. In JavaScript, 8.7 % 2.5 gives 1.1999999999999993, not 1.2, because 8.7 is stored as a binary float slightly below its typed value. The exact decimal answer is 1.2. The tool does not round anything, and it uses exact scaled-integer arithmetic to get the exact answer.
| Typed decimal | Plain JavaScript % result | Exact decimal result |
|---|---|---|
| 8.7 mod 2.5 | 1.1999999999999993 | 1.2 |
| 7.5 mod 2.5 | 0 | 0 |
| 10.5 mod 3 | 1.5 | 1.5 |
The tool also accepts scientific notation as input. You can type a number such as 1.5e10, but the tool does not convert to or from scientific notation. For example, 1.5e10 mod 7 = 6; 1e6 mod 999 = 1; and 2^1000 mod 13 = 3.
Divisibility and Time
The modulo calculator checks divisibility and wraps clock time, two jobs that both come down to one remainder.
Divisibility Check
A number a is divisible by b when a mod b = 0. For example, 15 mod 3 = 0, so 15 is divisible by 3. 17 mod 3 = 2, so 17 is not divisible by 3.
A number is even when n mod 2 = 0 and odd when n mod 2 = 1. For a negative number in JavaScript, test == 0, never == 1, because −3 % 2 = −1.
The divisibility rules for 3, 9, 11 and the rest belong to a separate Divisibility Test page. This page only checks a given pair.
Clock Arithmetic
A clock wraps an answer around its face: 14 mod 12 = 2, so 9 o'clock + 5 hours = 2 o'clock. In the same way, 25 mod 24 = 1, so 25 hours later is 1 hour later on a 24-hour clock. 9 o'clock + 3 hours = 12 o'clock.
Days also wrap around the week. 100 mod 7 = 2, so Tuesday + 100 days = Thursday. 365 mod 7 = 1, so the same date next year falls one weekday later.
Leap years follow the same idea. 2024 mod 4 = 0, so 2024 is a leap-year candidate. 2100 mod 400 = 100, so 2100 is NOT a leap year. 2000 mod 400 = 0, so 2000 was a leap year.
Modulo of a List and Modular Powers
Paste a list of numbers, and the modulo calculator returns each remainder in one table, so you can spot the divisible ones at a glance.
| Value | Remainder mod 5 | Divisible by 5 |
|---|---|---|
| 17 | 2 | No |
| 23 | 3 | No |
| 100 | 0 | Yes |
| 15 | 0 | Yes |
Modular powers are another useful application of remainders. The technique behind these is called modular exponentiation: reduce after every multiplication so the numbers stay small. These are worked examples only, as version 1 of the tool has no power mode. For example, 2^10 mod 7 = 2; 3^4 mod 5 = 1; 7^222 mod 10 = 9; and 2^100 mod 7 = 2.
One commonly circulated example needs correcting: 17^2001 mod 18 is not 1. The correct answer is 17, because 17 is −1 mod 18, and (−1)^2001 = −1, which is 17 mod 18.
Modular Arithmetic Rules
A modulo arithmetic calculator applies these rules to every sum and product it reduces.
Addition rule
For any numbers a, b and n: (a + b) mod n = ((a mod n) + (b mod n)) mod n. This works because you can reduce each number first and then reduce the sum. Take (18 + 27) mod 13 as an example: 18 mod 13 = 5 and 27 mod 13 = 1, so (18 + 27) mod 13 = 6.
Multiplication rule
For any numbers a, b and n: (a × b) mod n = ((a mod n) × (b mod n)) mod n. For example, (18 × 27) mod 13 = 5, because 18 mod 13 = 5 and 27 mod 13 = 1, and 5 × 1 = 5.
Congruence
Two numbers are congruent under the same modulus when their difference is a multiple of that modulus. For example, 38 ≡ 14 (mod 12) is true, because 38 − 14 = 24, and 12 divides 24. By contrast, 38 ≡ 15 (mod 12) is false, because 38 − 15 = 23, which 12 does not divide.
Inverses
A modular inverse is the number that multiplies back to 1 under the modulus: 4 × 7 = 28, and 28 ≡ 1 mod 9, so 7 undoes 4 under mod 9; 3 × 4 = 12 ≡ 1 mod 11, so 4 undoes 3 under mod 11; and 6 has no inverse mod 15, because 6 and 15 share the factor 3.
Under mod 12, only 1, 5, 7 and 11 have inverses, and each is its own inverse.
Modulo in Real Life
A modulo calculator turns each of these everyday situations into one quick check.
Every Tenth Purchase Free
A snack bar gives every 10th purchase free. The check is count mod 10 = 0: the 10th, 20th and 30th purchases are free, but the 15th is not, because 15 mod 10 = 5.
The Last Digit of a Number
A program prints the digits of a number with number % 10. For example, 483 % 10 = 3 takes the last digit, then 483 ÷ 10 = 48 moves to the next digit.
What Day Is It in 100 Days?
It is Tuesday. 100 mod 7 = 2, so in 100 days it is Thursday. The same Thursday comes up for 2^100 days, because 2^100 mod 7 = 2 as well.
Leap Years
2024 mod 4 = 0, so 2024 was a leap year. 2100 mod 400 = 100, so 2100 will not be one.
What the Calculator Does Not Solve
In version 1, this tool does not round to significant figures, does not convert to or from scientific notation, has no power mode and no inverse mode, and does not save or share results. Powers and inverses appear only as worked examples in the article. The Remainder page owns division-with-remainder as a topic, the Division page owns division itself, and the Divisibility Test page owns the divisibility rules.
Why Your Results May Differ
A modulo calculator can produce a different result from another tool when their conventions differ, so check the method, the divisor, and the sign before you compare answers.
- Truncated versus floored: −17 mod 5 is −2 truncated and 3 floored, the same inputs with two correct answers under two conventions.
- The % key differs by language: JavaScript's −7 % 3 = −1, Python's −7 % 3 = 2, and Excel's MOD(−340, 60) = 20, all floored or truncated by their own rule.
- The float trap: plain JavaScript gives 8.7 % 2.5 = 1.1999999999999993, while the exact decimal answer is 1.2.
- The negative-divisor range: 17 mod −5 = −3 floored, so the claim "the remainder is always between 0 and |n| − 1" is wrong for a negative divisor. The floored remainder takes the sign of the divisor.
- Mod zero is undefined: a mod 0 has no answer, and the tool shows an error rather than showing NaN.
- Rounding mid-way: when you reduce a big product, reduce each factor first and never round an intermediate quotient. For 129 × 143 × 149 × 164 × 179 mod 29, reducing the factors to 13, 27, 4, 19 and 5 gives 9, while rounding any step first gives the wrong remainder.
Questions Students Ask While Solving
How do you find the remainder of 17 divided by 5? Divide: 5 fits into 17 three times (5 × 3 = 15), and 17 − 15 = 2, so the remainder is 2. When the dividend is smaller than the divisor, the remainder is the dividend itself: 7 mod 10 = 7.
Find the remainder when 129 × 143 × 149 × 164 × 179 is divided by 29. Reduce each factor first: 129 mod 29 = 13, 143 mod 29 = 27, 149 mod 29 = 4, 164 mod 29 = 19, and 179 mod 29 = 5. Multiply the reduced factors: 13 × 27 × 4 × 19 × 5 = 133,380. Then reduce again: 133,380 mod 29 = 9. The answer is 9.
A student expected MOD(−340, 60) to be 40, confusing it with MOD(340, 60) = 40. Excel's MOD is floored, so MOD(−340, 60) = 20: −340 lies between −360 and −300, and −340 − (−360) = 20. The truncated remainder is −40.
Find the number that undoes 4 under mod 9, 19 under mod 141, 55 under mod 89, and 89 under mod 232. Some community answers say each number is 1, but all four are wrong. The correct numbers are 7, 52, 34 and 73, respectively: 4 × 7 = 28 = 3 × 9 + 1; 19 × 52 = 988 = 7 × 141 + 1; 55 × 34 = 1870 = 21 × 89 + 1; 89 × 73 = 6497 = 28 × 232 + 1.
FAQs
These questions cover the five modes this modulo calculator supports and the traps students meet most often.
Final Thought
Use this modulo calculator to check your work, keep the check equation a = q × n + r in mind, and the next remainder will take less time.
