Modulo Calculator

Updated July 2026

Enter a dividend (a) and a divisor (n) to compute a mod n — the remainder after division — plus the integer quotient and the relationship a = n×q + r. Negative numbers are shown with both the truncated and the Euclidean result. Everything runs privately in your browser.

The modulo operation a mod n gives the remainder left over after dividing a by n. For example, 17 mod 5 = 2, because 17 = 5 × 3 + 2. When n divides a exactly, the remainder is 0.
Must not be zero — division by zero is undefined.
a mod n (remainder)
Integer quotient floor(a/n)
Euclidean modulo (non-negative)
Truncated remainder (% sign follows a)
Relationship a = n×q + r
Divides evenly?

How this modulo calculator works

The modulo operation returns the remainder after one whole number is divided by another. Written a mod n, it answers the question: after taking out as many whole copies of n as possible from a, how much is left over? The leftover amount is the remainder, and the number of whole copies removed is the integer quotient q. Together they always satisfy the identity a = n × q + r.

For positive operands this is unambiguous. When the dividend a is negative, two different conventions disagree. The truncated form — used by the % operator in C, Java and JavaScript — rounds the quotient toward zero, so the remainder takes the sign of the dividend. The Euclidean (floored) form rounds the quotient down toward negative infinity, so the remainder is always non-negative. This calculator shows both, labelled clearly, so you can match whichever your language or formula expects.

Worked example: 17 mod 5 = 2, because 17 = 5 × 3 + 2. With a negative dividend the results split: −17 mod 5 is 3 under the Euclidean convention (−17 = 5 × −4 + 3), but −2 under the truncated % convention (−17 = 5 × −3 + −2). Both are "correct" — they just use different rounding rules for the quotient.

Reference note: this tool works with integers. The divisor must be non-zero, because dividing by zero leaves no defined remainder. Internally the Euclidean result is computed as ((a % n) + |n|) % |n| so it stays in the range 0 to |n| − 1.

Frequently asked questions

What is the modulo operation?
The modulo operation, written a mod n, gives the remainder left over after dividing the dividend a by the divisor n. For example, 17 mod 5 is 2, because 17 divided by 5 is 3 with 2 left over. It satisfies a = n × q + r.
How do I calculate a mod n?
Divide a by n and take the whole-number quotient q, then compute the remainder r = a − n × q. With the Euclidean convention the remainder is always between 0 and n − 1. For 17 mod 5 the quotient is 3 and the remainder is 2.
What is modulo of a negative number?
It depends on the convention. The truncated form (C, Java, JavaScript) keeps the sign of the dividend, so −17 % 5 is −2. The Euclidean form is always non-negative, so −17 mod 5 is 3. This calculator shows both.
What is the difference between mod and remainder?
For positive numbers they are identical. They differ only for negative dividends: the % operator keeps the dividend's sign (truncated), while mathematical modulo is usually non-negative (Euclidean). Always check which convention a tool uses.
What is 10 mod 3?
10 mod 3 is 1. Ten divided by three is three with one left over, since 3 × 3 = 9 and 10 − 9 = 1. The quotient is 3 and the remainder is 1, so 10 = 3 × 3 + 1.
What is modulo used for?
It tests divisibility (a mod n == 0), wraps values into a range like clock hours or array indices, extracts digits, and powers hashing, checksums and cryptography. Checking if a number is even is just n mod 2 == 0.
⚡ Modulo Calculator — by larely ↗

Related tools

Percent Error Calculator

Calculate percent error between an experimental and a true value.

Z-Score Calculator

Find a z-score and its percentile from a value, mean and standard deviation.

Cylinder Volume Calculator

Find a cylinder's volume, surface area and capacity in liters or gallons.

Half-Life Calculator

Calculate remaining quantity, decay constant and half-lives elapsed.

Percent Yield Calculator

Calculate reaction percent yield from actual and theoretical yield.

Trigonometry Calculator

Calculate sin, cos, tan and their inverses in degrees or radians.

Ideal Gas Law Calculator

Solve PV = nRT for pressure, volume, moles or temperature.

Weighted Average Calculator

Calculate a weighted average from value and weight pairs.

Probability Calculator

Calculate single-event probability and combined odds for two events.

Linear Interpolation Calculator

Interpolate a value between two known points, or solve the inverse.

Wavelength Calculator

Convert between wavelength, frequency and wave speed .

Force Calculator

Solve Newton's second law F = ma for force, mass or acceleration.

Browse all 251 free tools →