Modulo Calculator

Calculate modular arithmetic with clock visualization, congruence checker, modular inverse, equivalence class display, multiple mod conventions, and a properties reference table.

The integer to reduce
The modulus (divisor)
a mod m
2.00
17 mod 5 (non-negative)
JS % Result
2.00
Truncated remainder (JS/C convention)
Floor Mod
2.00
Always non-negative (Python convention)
Quotient
3.00
⌊17 / 5⌋
Modular Inverse
3.00
17⁻¹ ≡ 3 (mod 5)
GCD(a, m)
1.00
Coprime — inverse exists
Clock Position
5 o'clock
17 hours on a 12-hour clock
Clock Arithmetic (mod 12)
1
2
3
4
5
6
7
8
9
10
11
12

Equivalence Class [a] mod 5

All integers congruent to 17 mod 5:

-18-13-8-327121722

Congruence Checker

Check if two numbers are congruent mod 5

17 22 (mod 5) — Congruent ✓

Properties of Modular Arithmetic

PropertyRuleExample (mod 5)
Addition(a+b) mod m = ((a mod m)+(b mod m)) mod m(3+4) mod 5 = 2
Subtraction(a−b) mod m = ((a mod m)−(b mod m)+m) mod m(3−4) mod 5 = 4
Multiplication(a×b) mod m = ((a mod m)×(b mod m)) mod m(3×4) mod 5 = 2
Identitya mod m = a if 0 ≤ a < m2 mod 5 = 2
Selfm mod m = 05 mod 5 = 0
Periodicity(a + m) mod m = a mod m(2+5) mod 5 = 2

Common Applications

ApplicationModulusWhy
12-hour clock12Hours wrap around every 12
Day of week77 days in a week
Leap year check4, 100, 400Year divisibility rules
Even/odd check2n mod 2 = 0 → even
Hash tablestable sizeMap keys to bucket indices
Cryptography (RSA)large primesModular exponentiation
Check digits (ISBN)10 or 11Error detection
Planning notes, formulas, and examples

About the Modulo Calculator

The **Modulo Calculator** is a comprehensive tool for modular arithmetic — the mathematics of remainders and cyclic systems. It computes a mod m using multiple conventions (truncated, floored, Euclidean), finds the modular inverse when it exists, displays the full equivalence class, checks congruence between two numbers, and visualizes clock arithmetic on an interactive 12-hour dial.

Modular arithmetic underpins a remarkable range of fields: cryptography (RSA and Diffie-Hellman rely on modular exponentiation), computer science (hash tables, random number generators, circular buffers), calendar calculations (day of week, leap years), music theory (12-note octave), and everyday time-keeping (the 12-hour clock is arithmetic mod 12).

The concept is simple: a mod m equals the remainder when a is divided by m, but the sign convention varies by programming language. JavaScript and C use truncated division (remainder can be negative for negative dividends), while Python uses floored division (remainder always matches the sign of the divisor). This calculator shows both conventions side by side, so you always know the answer regardless of which language or context you work in.

Enter any integer and modulus to see seven output cards: the non-negative result, JS-style result, floor mod, quotient, modular inverse (via the Extended Euclidean Algorithm), GCD, and the clock-face position. The equivalence class section shows all integers congruent to your value, the congruence checker lets you test whether two numbers share the same remainder, and two reference tables cover properties and real-world applications.

When This Page Helps

This calculator is useful when plain remainder arithmetic is not enough. Many students and developers get tripped up by negative values because programming languages do not all define '%' the same way. By showing the non-negative result, the JavaScript-style remainder, and the floor-mod result together, the tool helps you move between textbook math, Python-style arithmetic, and JS or C implementations without guessing.

It also combines several modular-arithmetic tasks that are usually split across separate tools. You can check congruence, inspect the equivalence class, see the 12-hour clock interpretation, and test whether a modular inverse exists under the same modulus. That makes it useful for debugging code, studying discrete math, and working through cryptography or clock-arithmetic exercises with fewer context switches.

How to Use the Inputs

  1. Enter the value and modulus, then add a second value if you want to check congruence.
  2. Choose a preset such as "17 mod 5" or "100 mod 7" to confirm the setup before using your own numbers.
  3. Read the canonical non-negative result first, then compare it with the truncated and floored forms if signs matter.
  4. Use the quotient and equivalence-class output to see how the remainder is derived.
  5. Check the clock view when you want a concrete 12-hour interpretation of the same result.
  6. If the modular inverse exists, verify that the product returns 1 mod m before relying on it.
Formula used
a mod m = a − m × ⌊a/m⌋ (floor division). Modular inverse: a⁻¹ mod m exists iff GCD(a, m) = 1, found via the Extended Euclidean Algorithm.

Example Calculation

Result: 17 mod 5 = 2.

17 divided by 5 leaves a remainder of 2, so the canonical modulo result is 2 and the congruent class is all numbers of the form 2 + 5k.

Tips & Best Practices

  • When modulus is positive, the canonical modulo result is usually chosen from 0 through m - 1.
  • Negative dividends are where JS-style and Python-style remainder conventions diverge most often.
  • Use the congruence checker when you need to confirm that two values land in the same residue class.
  • The modular inverse exists only when the value and modulus are coprime.

Why Modulo Answers Can Differ Across Contexts

One of the most confusing parts of modular arithmetic is that software and mathematics sometimes emphasize different conventions. In pure math, people often want the canonical representative in the set ${0,1,2,dots,m-1}$ for positive $m$. In JavaScript, the '%' operator returns the truncated remainder, so negative dividends can produce negative outputs. This calculator exposes those conventions directly so you can tell whether a discrepancy is a bug or just a change in definition.

More Than A Remainder Calculator

The calculator is built around the idea that modular arithmetic forms classes, not isolated answers. The equivalence-class chips show numbers that all land in the same residue class, and the congruence checker verifies statements like $17 equiv 22 pmod 5$. The modular inverse card adds another layer by showing when division is possible in modular arithmetic, which depends on the gcd of the value and the modulus. That is the same condition used constantly in cryptography and number-theory proofs.

Using The Visual And Reference Sections

The clock display turns modulus 12 into something intuitive: each reduction maps to a visible hour position. The properties table then generalizes that intuition into reusable algebraic rules for addition, subtraction, multiplication, periodicity, and identity. The applications table grounds the topic in real problems such as weekdays, hash tables, leap-year rules, and RSA-style computations. Together, those sections make the calculator useful both for quick answers and for learning how modular systems behave.

Sources & Methodology

Last updated:

Frequently Asked Questions

  • The modulo operation (a mod n) returns the remainder when a is divided by n. For example, 17 mod 5 = 2 because 17 = 3 × 5 + 2.