Modulo calculator guide
Remainder, modulo, and Euclidean modulo are related but not identical. The remainder of truncated (toward-zero) division is the leftover after taking as many whole copies of the divisor as fit without passing zero — in JavaScript that leftover is `dividend % divisor`, and its sign follows the dividend. Mathematical modulo is a congruence: a ≡ b (mod m) means m divides a − b, which names a whole residue class rather than a single leftover. Euclidean modulo is the unique remainder in the half-open interval [0, |m|), the convention used by the Euclidean algorithm and most number-theory texts.
This calculator uses integers only. It reports the JavaScript remainder and the truncated quotient so the identity dividend = divisor × quotient + remainder holds even when the dividend is negative (for example −10 % 3 is −1, not 2). When that remainder is negative, the Euclidean remainder is shown as well, obtained by folding the leftover into [0, |divisor|).
How to use this modulo calculator
- Enter the dividend: Type the integer being divided, such as 10 or −10. Decimals, empty fields, and non-numeric text are rejected.
- Enter the divisor (modulus): Type a non-zero integer. Zero is undefined for division, so a divisor of 0 produces an error instead of a result.
- Select Calculate: Press Calculate to evaluate a mod m. Invalid input shows a descriptive error; a valid pair updates the remainder immediately.
- Read the remainder and the identity: The large value is the JavaScript remainder. Under it, the equation a = m × q + r confirms the truncated quotient. When r is negative, the Euclidean remainder in [0, |m|) is listed as well.
- Reset or share: Reset restores the example 10 mod 3 = 1. Copy the link to share the current dividend and divisor — they are encoded in the page URL.
Formula and variables
Integer division of a by m produces a quotient q and a remainder r satisfying a = q × m + r. This calculator takes q as the truncation of a / m toward zero, matching JavaScript `%`, so r has the same sign as a (or is zero). The Euclidean remainder r_E is then formed by adding |m| and reducing modulo |m|, which lands in [0, |m|) and never goes negative. Congruence a ≡ b (mod m) is a coarser statement: it holds whenever m divides a − b, whether or not a and b are the chosen remainders.
a = q × m + r, q = trunc(a / m), r = a % m, r_E = ((a % m) + |m|) % |m|- a — Dividend
- The integer being divided (the first operand of a mod m). (unitless integer)
- m — Divisor (modulus)
- The non-zero integer that a is divided by. (unitless integer)
- q — Quotient
- The truncated (toward-zero) integer quotient trunc(a / m). (unitless integer)
- r — Remainder
- The leftover a % m; its sign follows a, so it can be negative. (unitless integer)
- r_E — Euclidean remainder
- The unique residue of a modulo m in [0, |m|). (unitless integer)
Worked example: 10 mod 3
Find 10 modulo 3 using truncated division, then compare the same steps for −10 modulo 3 to see why JavaScript remainder and Euclidean remainder diverge.
- Dividend
- 10
- Divisor (modulus)
- 3
- Divide 10 by 3: 10 / 3 = 3.333…, and truncating toward zero gives q = 3.
- Remainder: r = 10 − 3 × 3 = 1, which is also 10 % 3 in JavaScript.
- Identity check: 3 × 3 + 1 = 10.
- Euclidean remainder: r is already in [0, 3), so r_E = 1 as well.
- Contrast with −10 mod 3: trunc(−10 / 3) = trunc(−3.333…) = −3, so r = −10 − (−3) × 3 = −1. JavaScript reports −10 % 3 === −1.
- Fold the leftover: r_E = ((−1) + 3) % 3 = 2, and −10 = 3 × (−4) + 2 under Euclidean division.
Result: 10 mod 3 = 1, with 10 = 3 × 3 + 1
One leftover after three groups of three is the everyday remainder. For a negative dividend the leftover of truncated division stays negative (−1), while Euclidean modulo wraps it to the standard residue 2. Both satisfy a congruence: −10 ≡ −1 ≡ 2 (mod 3).
Understanding your results
Remainder (JavaScript `%`)
The large number is a % m with truncated division: the leftover after taking as many whole copies of m as fit without crossing zero. Its sign follows the dividend, so −10 mod 3 is −1. A remainder of 0 means m divides a exactly.
Quotient and the division identity
The equation under the remainder is a = m × q + r with q = trunc(a / m). Truncation toward zero is not the same as mathematical floor: floor(−10 / 3) is −4, but trunc(−10 / 3) is −3. The identity is checked on every result, so the three displayed numbers always reconstruct the dividend.
Euclidean remainder
When r is negative, a second line reports the Euclidean remainder r_E in [0, |m|). It is the residue most textbooks and the Euclidean algorithm use. For positive dividends r and r_E coincide, so the extra line is omitted.
Assumptions
- Both operands are whole numbers (integers); decimals, fractions, and non-numeric text are rejected rather than truncated.
- The remainder uses JavaScript `%` semantics: truncated division toward zero, with the sign of r following the dividend.
- The Euclidean remainder is defined as ((a % m) + |m|) % |m| and therefore always lies in [0, |m|).
- Inputs must be exactly representable as safe integers (about 9 × 10¹⁵); larger values are rejected.
Limitations
- This calculator does not evaluate modular addition, subtraction, or multiplication of residue classes — only a single remainder.
- Floating-point operands, mixed numbers, and repeating decimals are out of scope; convert to integers first.
- Language conventions differ: Python’s `%` follows the divisor (floored division), while C, Java, and JavaScript follow the dividend. Results here match JavaScript, not Python.
- Congruence classes are infinite; the page reports two canonical representatives (truncated remainder and Euclidean remainder), not every integer congruent to a modulo m.
Common mistakes
- Treating remainder, modulo, and Euclidean modulo as synonyms. They agree for non-negative a and positive m, and they can disagree as soon as a is negative.
- Expecting −10 mod 3 to be 2 because “remainders are never negative.” That is Euclidean modulo; JavaScript remainder is −1.
- Using floor division for the quotient. This calculator truncates toward zero, so trunc(−10 / 3) is −3, not −4.
- Entering a decimal such as 10.5; modulo here is defined only for integers.
- Using 0 as the divisor. Division by zero is undefined, so no remainder exists.
- Reading a ≡ b (mod m) as “a divided by m equals b.” Congruence means m divides a − b, not that b is the displayed remainder.
Practical use cases
Check divisibility and leftover counts
A remainder of 0 means the divisor divides the dividend exactly — 10 mod 5 = 0. A non-zero remainder is the leftover after packing as many complete groups as possible, which is the usual school remainder for positive integers.
Clock arithmetic and repeating schedules
Hours wrap every 12 or 24, weekdays every 7, and degrees every 360. Those cycles use a non-negative residue, so convert a negative leftover to the Euclidean remainder before mapping it onto a clock or calendar.
Match programming-language remainder
JavaScript, C, C++, C#, and Java all take the remainder sign from the dividend. Use this calculator to predict `%` in those languages. For Python or mathematical residue, read the Euclidean remainder instead.
Euclidean algorithm and greatest common divisor
The Euclidean algorithm repeatedly replaces (a, m) with (m, a mod m) until the remainder is 0. That algorithm needs a non-negative remainder; the Euclidean remainder on this page is the value those steps use.
Planning and decision guide
Choose the remainder that matches your context
If you are checking JavaScript (or C/Java) `%`, use the large remainder, including a leading minus. If you are working a number-theory exercise, hashing into a non-negative bucket, or stepping the Euclidean algorithm, use the Euclidean remainder. Both are shown whenever they differ so you do not have to convert by hand.
Verify with the division identity
Any claimed remainder is wrong unless q × m + r reconstructs a. For 10 mod 3 the check is 3 × 3 + 1 = 10; for −10 mod 3 it is (−3) × 3 + (−1) = −10. The Euclidean pair uses a different quotient: (−4) × 3 + 2 = −10.
Keep the modulus non-zero and integral
Modulo is a statement about integer divisibility. Convert measurements to whole units before taking a remainder, and never use 0 as the modulus. For GCF work that consumes remainders, use the GCF and LCM calculator after you have integers.
Frequently asked questions
What is the difference between remainder and modulo?
Remainder is the leftover of a chosen integer-division convention. Modulo in number theory is congruence: a ≡ b (mod m) means m divides a − b. A remainder is one representative of that congruence class. This calculator reports the truncated remainder (JavaScript `%`) and, when it differs, the Euclidean representative in [0, |m|).
Why is −10 mod 3 equal to −1 here instead of 2?
JavaScript’s remainder operator uses truncated division, so the leftover keeps the sign of the dividend: −10 % 3 === −1. The Euclidean remainder of −10 modulo 3 is 2, and both are congruent modulo 3. The calculator shows −1 as the primary remainder and 2 as the Euclidean remainder so the two conventions are not mixed up.
What is Euclidean modulo?
Euclidean modulo is the unique remainder r_E satisfying a = q_E × m + r_E with 0 ≤ r_E < |m|. It is computed here as ((a % m) + |m|) % |m|. Number theory, the Euclidean algorithm, and most “clock arithmetic” examples use this non-negative residue.
What is 10 mod 3?
10 divided by 3 is 3 with leftover 1, so 10 mod 3 = 1 and 10 = 3 × 3 + 1. Because 1 already lies in [0, 3), the Euclidean remainder is also 1.
What is 10 mod 5?
5 divides 10 exactly, so the remainder is 0, the quotient is 2, and 10 = 5 × 2 + 0. A remainder of 0 is the divisibility test.
Can the divisor be negative?
Yes. The remainder still follows the dividend, and the Euclidean remainder still lands in [0, |m|). For example 10 % −3 is 1, matching truncated division, while the Euclidean remainder is 1 as well because it is already non-negative.
Why can’t the divisor be zero?
Division by zero is undefined, so there is no quotient or remainder. The calculator rejects a divisor of 0 instead of returning a dummy value.
How is the quotient calculated?
The quotient is trunc(dividend / divisor), integer division toward zero. That is the convention that makes q × m + r reconstruct the dividend when r is the JavaScript remainder. Floor division (used by Python) would pair with a remainder whose sign follows the divisor instead.
Sources and review
- Modulo — MathWorld — A Wolfram Resource. Accessed 2026-08-23.
- Remainder (%) — MDN Web Docs. Accessed 2026-08-23.
- What is modular arithmetic? — Khan Academy. Accessed 2026-08-23.
Reviewed 2026-08-23.