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.

Loading calculator…

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.

Tip: 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:

a=q×b+r,0r<ba = q \times b + r, \qquad 0 \le r < b

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

5÷2=2 remainder 1    5mod2=15 \div 2 = 2 \text{ remainder } 1 \;\Rightarrow\; 5 \bmod 2 = 1

Check: 2×2+1=52 \times 2 + 1 = 5 ✓.

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.

1mod2=1,5mod10=51 \bmod 2 = 1, \qquad 5 \bmod 10 = 5

Using mod to test divisibility

x is a multiple of n if and only if x mod n = 0:

  • 496mod4=0496 \bmod 4 = 0 → 496 is a multiple of 4.
  • 226mod4=2226 \bmod 4 = 2 → 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.

8mod2=0 (even),7mod2=1 (odd)8 \bmod 2 = 0 \text{ (even)}, \qquad 7 \bmod 2 = 1 \text{ (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. 5÷2=25 \div 2 = 2 remainder 11, so 5mod2=15 \bmod 2 = 1.
What is the modulo operation?
Modulo (written amodba \bmod b or a%ba \% b) returns the remainder rr left over when aa is divided by bb, where 0r<b0 \le r < b. It is defined by the identity a=q×b+ra = q \times b + r, with qq 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. 1mod2=11 \bmod 2 = 1 and 5mod10=55 \bmod 10 = 5.
How do I use mod to check if a number is divisible by another?
A number xx is divisible by nn — and xx is a multiple of nn — exactly when xmodn=0x \bmod n = 0. For example 496mod4=0496 \bmod 4 = 0, so 496 is a multiple of 4, while 226mod4=2226 \bmod 4 = 2, 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 (8mod2=08 \bmod 2 = 0); a remainder of 1 means it is odd (7mod2=17 \bmod 2 = 1).
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.

Related calculators