Math · Modular arithmetic

Modulo Calculator

Calculate a mod n, see the quotient and Euclidean remainder, compare programming-language remainder behavior, and understand modulo through live visual explanations.

Report error
a mod n
—
Euclidean remainder
Quotient q
—
floor(a / |n|)
JavaScript %
—
remainder operator

Division identity

See how the quotient part and remainder rebuild the dividend.

LIVE

Remainder on the cycle

The remainder moves through a repeating 0 → n−1 cycle.

LIVE

Nearby dividends

Watch the remainder repeat as a changes one step at a time.

LIVE

Cycle position

A radial view of where the current remainder sits inside the modulus.

LIVE

Nearby dividend table

Live window: a − 4 to a + 4
Dividend aQuotient qRemainder rIdentity check
LIVE MODULO INTELLIGENCE

Read the remainder, not just the number.

MetricCurrent valueWhat it tells you
Euclidean remainder2The non-negative remainder in the Euclidean convention.
Quotient3How many complete modulus cycles fit into the dividend.
Cycle position40.0%Where the remainder sits within one modulus cycle.
Identity check17 = 3 × 5 + 2Quotient × modulus + remainder reconstructs the dividend.
17 mod 5 = 2. The remainder is 2 after three complete groups of 5.
CONCEPT

What is modulo?

Modulo is the operation that tells you what remains after one integer is divided by another. If a = qn + r, then a mod n = r under the Euclidean convention used by this calculator.

01
a
Dividend — the number being divided.
02
÷
Divide by the modulus.
03
q
Count complete groups.
04
r
Keep the remainder.
05
≡
Numbers with the same remainder are congruent.
Think in cycles: modulo turns an unlimited number line into a repeating cycle. On a 12-hour clock, 15:00 and 3:00 occupy the same position because 15 mod 12 = 3.
0123 repeating remainder cycle after n steps, the pattern starts again
FORMULAS

Modulo formulas and the division identity

The most useful way to understand modulo is to keep the complete division equation visible. The remainder is not an isolated number; it is the part left after complete groups have been removed.

a = q|n| + r,   0 ≤ r < |n|

Find the remainder

Compute q = floor(a / |n|), then calculate r = a − q|n|. The result r is the Euclidean remainder.

Check the answer

Rebuild the dividend: q|n| + r must equal a. This identity is the fastest way to catch an arithmetic mistake.

Modulo and congruence

Two integers a and b are congruent modulo n when their difference is divisible by n. This is written a ≡ b (mod n). Equivalently, they have the same remainder when divided by n.

a ≡ b (mod n)   ⇔   n divides (a − b)   ⇔   a mod n = b mod n
EXAMPLES

Modulo examples, step by step

The same three-step pattern works for small remainders, large dividends, and clock-style cycles: divide, keep the complete groups, then read the remainder.

Example 01

17 mod 5

17 ÷ 5 = 3 remainder 2
17 = 3 × 5 + 2
17 mod 5 = 2
Example 02

250 mod 24

250 ÷ 24 = 10 remainder 10
250 = 10 × 24 + 10
250 mod 24 = 10
Example 03

1 mod 10

10 fits into 1 zero complete times
1 = 0 × 10 + 1
1 mod 10 = 1
Example 04

100 mod 7

100 ÷ 7 = 14 remainder 2
100 = 14 × 7 + 2
100 mod 7 = 2

Common modulo values

Quick reference
ExpressionQuotientRemainderCheck
1 mod 1101 = 1×1 + 0
5 mod 2215 = 2×2 + 1
5 mod 3125 = 1×3 + 2
6 mod 3206 = 2×3 + 0
10 mod 33110 = 3×3 + 1
17 mod 35217 = 5×3 + 2
100 mod 7142100 = 14×7 + 2
250 mod 241010250 = 10×24 + 10
MODULAR ARITHMETIC

How modulo behaves in arithmetic

Modulo lets arithmetic wrap around a fixed cycle. You can reduce numbers before adding or multiplying, which is especially useful when the original numbers are large.

(a + b) mod n = ((a mod n) + (b mod n)) mod n
(a − b) mod n = ((a mod n) − (b mod n)) mod n
(a × b) mod n = ((a mod n) × (b mod n)) mod n
Example: 11 + 7 mod 4 = 18 mod 4 = 2. Reducing first gives (11 mod 4 + 7 mod 4) mod 4 = (3 + 3) mod 4 = 2.

Why this matters

These identities make it possible to keep intermediate numbers small. Modular arithmetic is therefore useful in algorithms, checksums, scheduling, repeating patterns, and cryptography.

NEGATIVE VALUES

Why negative modulo results can differ

Negative values are where mathematical modulo and programming-language remainder operators can appear to disagree. The underlying division identity is the same, but the chosen quotient convention can change the representative remainder.

Euclidean convention

For a positive modulus, choose a non-negative remainder. For example, −9 = (−3) × 4 + 3, so the Euclidean remainder is 3.

JavaScript %

JavaScript's remainder operator keeps the sign of the dividend. Therefore −9 % 4 is −1. This calculator shows that value separately from the Euclidean result.

Important: when code and mathematics meet, always check the convention used by the language or library. Different implementations can choose different representatives for negative inputs.
APPLICATIONS

Where modulo is used

Modulo is a simple operation with a surprisingly broad role. Whenever a quantity repeats in a fixed cycle or you need to test divisibility, modulo is often the right tool.

Application map

Concept → practical use
ApplicationModulo ideaExample
Clock arithmeticWrap around a fixed cycle15 mod 12 = 3
Divisibility testsCheck whether r = 0496 mod 4 = 0
Repeating schedulesMap a count to a cycle positionday mod 7
ChecksumsReduce a running totaldigit-based checks
AlgorithmsKeep values inside a bounded rangeindex mod length
CryptographyArithmetic over finite cyclesmodular exponentiation
FAQ

Modulo calculator FAQ

What does modulo mean?
Modulo returns the remainder associated with a division. In the Euclidean convention, a = qn + r with 0 ≤ r < |n|.
How do I calculate a mod n by hand?
Divide a by |n|, take the floor of the quotient, multiply that quotient by |n|, and subtract the product from a.
What is 17 mod 3?
17 = 5 × 3 + 2, so 17 mod 3 = 2.
What happens when the remainder is zero?
A remainder of zero means the dividend is divisible by the modulus.
Why can −9 mod 4 and −9 % 4 differ?
The mathematical Euclidean convention selects a non-negative remainder, while JavaScript's % operator uses its language-specific remainder rule and returns −1 for −9 % 4.
Can the modulus be zero?
No. Division by zero is undefined, so modulo by zero is not a valid operation.