# Modulo calculator

Canonical HTML: https://easycalculatorsonline.com/math/modular-arithmetic/

Find the nonnegative remainder and congruence class.

Interactive calculations run in your browser. Values below are the published example, not a calculation for your circumstances.

## Calculator inputs

| Input | Example value | Constraints and options |
| --- | --- | --- |
| Integer dividend | 29 | min: -1000000000000. max: 1000000000000. step: 1 |
| Positive integer modulus | 12 | min: 1. max: 1000000000000. step: 1 |

**International formulas and units**

Use the units and assumptions stated on this page. Mathematical definitions apply across countries; material, device and measurement conditions remain your inputs.

## Published example result

> Modulo calculator
> Nonnegative remainder: 5
> Euclidean quotient: 2
> Euclidean remainder 0≤r<m, including for negative dividends.
> https://easycalculatorsonline.com/math/modular-arithmetic/

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**

| Input or output | Value |
| --- | --- |
| Integer dividend | 29 |
| Positive integer modulus | 12 |
| Nonnegative remainder | 5 |

### 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

- [OpenStax: clock arithmetic ↗](https://openstax.org/books/contemporary-mathematics/pages/3-7-clock-arithmetic)

[How we check calculations and what verification covers](https://easycalculatorsonline.com/methodology/)

## Related calculators

[**Modular multiplicative inverse ↗**

Find an integer inverse modulo a coprime modulus.](https://easycalculatorsonline.com/math/modular-inverse/)[**Modular exponentiation ↗**

Compute aᵉ modulo m without forming a huge power.](https://easycalculatorsonline.com/math/modular-exponentiation/)[**Positive divisors ↗**

List all positive divisors and their sum.](https://easycalculatorsonline.com/math/divisors-list/)

[← Explore all calculators](https://easycalculatorsonline.com/#browse)

## Publisher and access

Published by Wolfpack Labs. Free to use; no account or payment required.

[Email wolfpack.labs.in@gmail.com](mailto:wolfpack.labs.in@gmail.com)

[About](https://easycalculatorsonline.com/about/) · [Methodology](https://easycalculatorsonline.com/methodology/) · [Contact](https://easycalculatorsonline.com/contact/) · [Privacy](https://easycalculatorsonline.com/privacy/) · [Terms](https://easycalculatorsonline.com/terms/)
