Calculate modular arithmetic with clock visualization, congruence checker, modular inverse, equivalence class display, multiple mod conventions, and a properties reference table.
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.
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.
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.
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.
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.
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.
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.
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.
Different programming languages handle negative modulo differently. In mathematics, the result is always non-negative: −7 mod 3 = 2. In some languages like C, −7 % 3 = −1.
Modulo is used for checking even/odd (n%2), cycling through arrays (index % length), hash functions, clock arithmetic, and determining divisibility. It is also common anywhere a repeating cycle or wraparound index is needed.
Clock arithmetic is modular arithmetic with modulus 12 or 24. Adding hours wraps around when you exceed the modulus, which is exactly what the modulo operation computes — the position within one full cycle.
Two integers a and b are congruent modulo n if they have the same remainder when divided by n, written a ≡ b (mod n). Congruent numbers belong to the same equivalence class.
The modular inverse of a mod n is the value x such that a·x ≡ 1 (mod n). It exists if and only if GCD(a, n) = 1, and this property is foundational in public-key cryptography such as RSA.