Modulo Calculator
Compute a mod b — the remainder left over after dividing a by b — with the quotient, the check identity, and a step-by-step divisibility test shown.
How to use this calculator
Enter a dividend (a) and a divisor (b). The calculator returns a mod b — the remainder left over after dividing a by b — along with the quotient and a check that confirms the answer.
a mod b = 0 is the standard way programs test divisibility: it means b divides a evenly, so a is a multiple of b.The modulo identity
Every division with remainder satisfies one identity:
Here q is the whole-number quotient (how many times b fits into a) and r is the remainder — that remainder is exactly a mod b. Plugging numbers into the identity is also how the calculator checks its own answer: q × b + r must equal a back.
Worked example — 5 mod 2
Check: ✓.
When the divisor is bigger than the dividend
If b > a, then b fits into a zero times: the quotient is 0 and the remainder is a itself.
Using mod to test divisibility
x is a multiple of n if and only if x mod n = 0:
- → 496 is a multiple of 4.
- → 226 is not a multiple of 4.
This is the classic way code checks whether one number divides another, without doing a full division and comparing to an integer.
Even or odd with mod 2
The most common special case is mod 2: a remainder of 0 means the number is even, a remainder of 1 means it is odd.
A note on negative numbers
This calculator works with non-negative dividends and divisors only. Once negative numbers enter the picture, "mod" splits into two different conventions — floored modulo (remainder takes the sign of the divisor) and truncated modulo (remainder takes the sign of the dividend) — and programming languages disagree on which one % implements. Keeping both inputs non-negative avoids that ambiguity entirely; the result is exact and matches every convention.
Modulo and modular arithmetic
Because a mod b always lands in the range 0 to b − 1, it is the foundation of modular arithmetic — the "clock arithmetic" used in cryptography, hashing, and scheduling, where values wrap back around to 0 once they reach b.
Frequently asked questions
- What does 5 mod 2 mean?
- 5 mod 2 asks for the remainder when 5 is divided by 2. remainder , so .
- What is the modulo operation?
- Modulo (written or ) returns the remainder left over when is divided by , where . It is defined by the identity , with the whole-number quotient.
- What happens when the divisor is bigger than the dividend?
- The quotient is 0 and the remainder is the dividend itself, since the divisor does not fit even once. and .
- How do I use mod to check if a number is divisible by another?
- A number is divisible by — and is a multiple of — exactly when . For example , so 496 is a multiple of 4, while , so 226 is not.
- How do I check if a number is even or odd using mod?
- Take the number mod 2. A remainder of 0 means the number is even (); a remainder of 1 means it is odd ().
- Why doesn't this calculator accept negative numbers?
- The sign convention for modulo with negative operands differs between programming languages (floored vs. truncated division give different results), so this calculator sticks to the unambiguous non-negative case described here.