Enter the dividend (x) and the divisor (y) to calculate x mod y instantly. The calculator shows the remainder, the formula and the complete step-by-step.
Modulo Calculator
x mod y = r
How to use the calculator
- Enter the dividend x — the number to be divided.
- Enter the divisor y — must be non-zero.
- The remainder r and the step-by-step appear automatically.
- Click Clear to reset.
What is the modulo operator
The modulo operator (written mod or %) returns the
remainder of the integer division of x by y. The formula is:
x mod y = x − y × floor(x / y)
where floor is the floor function (rounds down). The result is always a value between 0 and |y| − 1.
Examples
| x | y | r = x mod y | Verification |
|---|---|---|---|
| 12 | 3 | 0 | 12 = 3 × 4 + 0 |
| 17 | 5 | 2 | 17 = 5 × 3 + 2 |
| 10 | 7 | 3 | 10 = 7 × 1 + 3 |
| −7 | 3 | 2 | −7 = 3 × (−3) + 2 |
| 100 | 13 | 9 | 100 = 13 × 7 + 9 |
Uses of modulo in mathematics
- Parity: n mod 2 = 0 (even) or 1 (odd).
- Clock: hours in modulo 12 or 24.
- Cryptography: RSA and other algorithms use modular arithmetic.
- Hashing: index = key mod table size.
- Divisibility: a divides b if b mod a = 0.
Frequently asked questions
What is the modulo operator?
The modulo operator (mod or %) returns the remainder of the
integer division of x by y. For example, 12 mod 5 = 2, since 12 = 5 × 2 + 2.
How do you calculate x mod y manually?
1. Divide x by y and find the integer quotient q = floor(x/y). 2. Multiply: q × y. 3. Subtract: r = x − q × y. Example: 17 mod 5 → q = 3 → r = 17 − 15 = 2.
Can modulo be negative?
In this calculator we use the Euclidean definition: the remainder is always ≥ 0. So −7 mod 3 = 2 (not −1). In some programming languages (C, Java) the result can be negative when x < 0.
What is the difference between mod and remainder?
For positive numbers they are identical. For negatives they differ: the Euclidean definition (mod) always returns a value ≥ 0, while "remainder" in some languages follows the sign of the dividend.
Read also…
