Modulo Calculator

This modulo calculator finds a mod n — the remainder after dividing a by n — with the quotient and a non-negative form shown.

a mod n (remainder)
Non-negative form
Quotient

How to Calculate a Modulo

Enter the dividend a and the divisor n.

1

Enter a and n

a is the number being divided, n is what you divide by.

2

Read the remainder

a mod n is what is left over after taking out as many whole n as possible.

3

Non-negative form

When a is negative, the plain remainder is negative; the non-negative form wraps it into 0…n−1.

Frequently Asked Questions

What does modulo mean?
The expression a mod n is the remainder left when a is divided by n. For example 17 mod 5 = 2, because 17 = 3×5 + 2. The result is always smaller in magnitude than n, so mod 5 can only return 0, 1, 2, 3 or 4 for positive inputs. Modulo is what makes clock arithmetic work: 15 mod 12 = 3, which is why 15:00 is 3 o'clock.
What is the modulo of a negative number?
For a negative number, the plain remainder keeps the sign of a, so −17 mod 5 = −2 in languages such as C, Java and JavaScript. The non-negative Euclidean form instead returns 3, staying inside the range 0 to n − 1. Both are consistent, because −17 = (−4)×5 + 3 just as much as (−3)×5 − 2. This calculator shows both results so you can pick the convention your language or your homework uses.
How is modulo different from remainder?
Modulo and remainder agree for positive numbers and differ only in how they treat negatives. For 17 and 5 both give 2, but for −17 and 5 the remainder is −2 while the modulo is 3. The % operator in Python returns the non-negative modulo, whereas C, Java and JavaScript return the signed remainder. This calculator shows both values so the difference is explicit.
Is my data sent anywhere?
Nothing you type is sent anywhere. The modulo calculator runs entirely in your browser with JavaScript, so the values of a and n never leave your device. There is no account, no upload step and nothing is logged. The page keeps working offline once it has loaded.