Easy CalculatorsOnline
A little less guesswork.

Math · EVERYDAY CLARITY

Modulo calculator

Find the nonnegative remainder and congruence class.

Units & number format

Number formatting changes the display; the interface and guides are in English. Dates use calendar controls; numeric lists use decimal points and comma or space separators.

01 · CALCULATE

Work out your numbers

Your inputs stay in this browser.

Example result · using the values shown

Nonnegative remainder
5
Euclidean quotient2
See visual ↓

Euclidean remainder 0≤r<m, including for negative dividends.

02 · SEE THE RESULT

Your numbers, pictured

Example visualization

Dividend = quotient × modulus + remainder

2×12+5
Calculated result29

The remainder is always nonnegative and less than the positive modulus.

03 · UNDERSTAND THE METHOD

How the modulo calculator works

Modular arithmetic groups integers by the remainder they leave after division by a positive modulus. It is often described through a clock, where adding hours wraps around a fixed cycle. This calculator returns the nonnegative residue from zero through one less than the modulus, including when the original integer is negative. That convention is useful for cyclic indexing and differs from programming languages that preserve the dividend’s sign in a remainder operation.

The formula and its variables

r = ((a % m) + m) % m, with m > 0 and 0 ≤ r < m; a = qm + r
a
Signed integer being reduced.
m
Positive integer modulus or cycle length.
r
Nonnegative remainder, also called the residue.

The calculation, step by step

  1. Enter an integer and a strictly positive integer modulus. A zero modulus cannot define division or a remainder.
  2. Find a remainder and normalize it into the interval beginning at zero and ending just below the modulus. This normalization matters for negative dividends.
  3. Check that subtracting the residue from the original integer leaves an exact multiple of the modulus. Interpret that multiple as a whole number of cycles.

A worked example

For 29 modulo 12, two whole cycles account for 24 and the residue is 5. For −5 modulo 12, the nonnegative residue is 7 because −5 = (−1 × 12) + 7. Both −5 and 7 belong to the same class modulo 12. A multiple such as 36 modulo 12 produces zero rather than twelve, because residues are always smaller than the modulus.

Example inputs and calculated output
Integer dividend29
Positive integer modulus12
Nonnegative remainder5

How to read the result and visual

The residue identifies a position within a cycle, while the original integer can count multiple cycles in either direction. Values differing by a whole multiple of the modulus share the same residue. This page labels positions numerically from zero; a wall clock often labels its zero position as twelve, so adapt that final display convention when explaining time.

Assumptions, rounding, and limitations

Inputs must be whole numbers in the supported exact numeric range. The tool calculates one reduction, not modular inverses, modular exponentiation, or a cryptographic protocol. Its nonnegative convention may differ from a spreadsheet or programming language’s raw remainder operator for negative inputs. Decimal division should be handled with a different calculator.

Frequently asked questions

Why is −5 modulo 12 equal to 7?

Adding one twelve-unit cycle to −5 reaches the equivalent nonnegative position seven.

Can a remainder equal the modulus?

No. An additional full cycle would be removed, leaving zero in that case.

Reference sources

How we check calculations and what verification covers