Math
Modulo Calculator
Enter a dividend and a modulus to get a mod n with the quotient, the equation a = n × q + r, and the congruence class.
Negative and decimal inputs are handled exactly, and the panel shows how the floored (math, Python), truncated (JavaScript, C), and Euclidean conventions differ, so you always know which remainder your class or programming language expects.
The number being divided. Negatives and decimals are fine.
The number you divide by. Cannot be 0.
Only matters when a or n is negative. All three agree for positive inputs.
Try an example
Result
a mod n
—
- Quotient
- —
- Division equation
- —
- Truncated remainder
- —
- Congruence
- —
Student quick launch
Grade planning, algebra checks, and formulas students reach for most.
Study path
Use this calculator with
Follow these when you want the formula behind the answer, a short lesson, or nearby tools in the same topic.
What the modulo calculator solves
The The remainder left over after dividing one whole number by another. operation returns the remainder after division. 17 mod 5 = 2 because 5 fits into 17 three times with 2 left over: 17 = 5 × 3 + 2. Modulo powers clock arithmetic, parity checks, cyclic schedules, hash functions, and every congruence in number theory. This calculator computes it exactly for whole numbers, negatives, and decimals.
Floored vs truncated remainders
For positive numbers every convention agrees. Once a or n is negative, the quotient can be rounded toward negative infinity (floored) or toward zero (truncated), and the remainder changes with it. Math classes, Python, Ruby, and Excel's MOD use floored division; JavaScript, C, C++, Java, and Go use truncated division.
| Expression | Floored (Python) | Truncated (JavaScript) | Euclidean |
|---|---|---|---|
| 17 mod 5 | 2 | 2 | 2 |
| -17 mod 5 | 3 | -2 | 3 |
| 17 mod -5 | -3 | 2 | 2 |
| -17 mod -5 | -2 | -2 | 3 |
Congruence classes
Two integers are congruent modulo n when they leave the same remainder. Writing 17 ≡ 2 (mod 5) says 17 and 2 sit in the same class; so do 7, 12, 22, and -3. The calculator lists nearby members of the class so you can see the pattern of adding or subtracting n.
How to use it
- Enter the dividend a and the modulus n (n cannot be 0).
- Pick the remainder convention your class or programming language uses; it only changes the answer for negative inputs.
- Read a mod n in the panel along with the quotient and the equation a = n × q + r.
- Use the clock visual to see the wrap-around, and Show the work for the divide-multiply-subtract steps.
How to read the answer
The remainder is what is left after removing as many whole copies of n as the convention allows. With floored division the remainder always has the sign of n (or is 0); with truncated division it has the sign of a; with Euclidean division it is never negative. The quotient tells you how many full cycles were removed, which on a clock is the number of complete turns.
Common mistakes and edge cases
- Assuming -17 mod 5 is -2 in every setting. Python and most math courses say 3; JavaScript says -2. Check the convention.
- Using the modulus 0. Division by zero is undefined, so a mod 0 has no value.
- Confusing the remainder with the decimal part: 17 ÷ 5 = 3.4, but 17 mod 5 is 2, not 0.4.
- Trusting floating-point modulo with decimals: 0.1 + 0.2 style errors creep into results like 10 % 0.3. This page uses exact decimal arithmetic.
- Reading a ≡ b (mod n) as 'a equals b'. It means a and b differ by a multiple of n.
Worked examples
Basic remainder
17 = 5 × 3 + 2
a mod n
2
Negative dividend, floored
-17 mod 5 = 3 because -17 = 5 × (-4) + 3.
a mod n
3
Negative dividend, truncated
JavaScript gives -17 % 5 = -2.
a mod n
-2
Decimal modulo
7.5 mod 2 = 1.5 exactly.
a mod n
1.5
Exact multiple
The remainder is 0 when n divides a.
a mod n
0
Clock arithmetic
27 hours after midnight on a 24-hour clock is 3 o'clock.
a mod n
3
Modulus zero
Undefined.
a mod n
Error
Frequently asked questions
What does mod mean in math?+
a mod n is the remainder when a is divided by n. 17 mod 5 = 2 because 17 = 5 × 3 + 2. The word comes from 'modulus', the number you divide by.
How does modulo work with negative numbers?+
It depends on how the quotient is rounded. Floored division (Python, math class) gives -17 mod 5 = 3; truncated division (JavaScript, C) gives -2. Both satisfy -17 = 5 × q + r, they just choose different q.
Why does Python give a different answer than JavaScript?+
Python's % floors the quotient toward negative infinity, so the remainder takes the sign of the divisor. JavaScript's % truncates toward zero, so the remainder takes the sign of the dividend. Switch the convention above to see both.
Can I take the modulo of a decimal?+
Yes. 7.5 mod 2 = 1.5 and 5.75 mod 0.5 = 0.25. This calculator uses exact decimal arithmetic, so there is no floating-point drift.
What is a mod 0?+
Undefined. Division by zero has no quotient, so there is no remainder either.
What does a ≡ b (mod n) mean?+
a and b are congruent modulo n: they leave the same remainder, or equivalently n divides a - b. For example 17 ≡ 2 (mod 5) and 17 ≡ -3 (mod 5).
How is modulo used in real life?+
Clocks (27 hours after midnight is 3 o'clock), calendars (which weekday is 100 days from now), check digits on credit cards and ISBNs, hashing, and cryptography all rely on remainders.
About this calculator
- Written by
- mathcheck editorial team
- Last reviewed
- September 4, 2026
Method
- Uses the values entered by the user and stable formulas documented on the page.
Related calculators
Remainder Calculator
Divide two whole numbers and get the quotient and remainder, the check equation a = b × q + r, the mixed-number, fraction, and decimal forms of the same division, and both sign conventions for negatives.
Long Division Calculator
Divide whole numbers with every classic long-division step shown — divide, multiply, subtract, bring down — plus quotient, remainder, decimal answer, and a check line.
Divisibility Test Calculator
Test any whole number against the divisibility rules for 2 through 13 with the actual rule work shown (digit sums, last digits, the 7 and 13 chop tricks), plus a custom divisor with quotient and remainder.
GCF and LCM Calculator
Find the greatest common factor and least common multiple for a list of positive integers with factor steps.
Adding Fractions Calculator
Add up to five fractions or mixed numbers. Finds the least common denominator with prime factors, rewrites each fraction, adds, simplifies, and shows the mixed-number and decimal forms with a fraction-strip picture.
Area Calculator
Find the area of 11 shapes — rectangle, square, triangle (base-height, three sides, or SAS), circle, trapezoid, parallelogram, rhombus, ellipse, regular polygon, sector, and kite — with the formula, substitution, square-unit labels, and a diagram.
Last updated: September 4, 2026