Modulo Calculator — Free Mod, Remainder & Clock Math 2026 | AllInOneTools
% Free Math Tool

Modulo Calculator

Calculate a mod b (remainder after division). Interactive clock visualization, number line, step-by-step division, congruence classes, and modular arithmetic table.

mod
a mod b
Remainder
--
a mod b
--
Quotient
--
Remainder
--
a = q×b + r
--
Even/Odd
--
Divisible?
--
Modular Arithmetic Table (a mod 2 through mod 12)
ModResultQuotientEquation
Congruence Class: Numbers ≡ r (mod b)
💡 Modulo Insight

Modulo Calculator: Complete Guide to Remainder, Modular Arithmetic, and Clock Math

The modulo operation (mod) finds the remainder after integer division. Written as a mod b, it answers: "when you divide a by b, what is left over?" This seemingly simple operation is one of the most powerful tools in mathematics and computer science, underpinning everything from telling time to securing internet communications. Every clock is a mod 12 (or mod 24) calculator, every calendar uses mod 7 for days of the week, and every encryption algorithm relies on modular arithmetic with enormous numbers.

The Division Algorithm

For any integers a and b (with b > 0), there exist unique integers q (quotient) and r (remainder) such that a = q × b + r, where 0 ≤ r < b. The modulo operation returns r. Example: 17 mod 5. Divide: 17 ÷ 5 = 3 remainder 2. So 17 = 3 × 5 + 2, and 17 mod 5 = 2. This is the Division Algorithm, a foundational theorem in number theory. The quotient tells how many complete groups of b fit into a, and the remainder is what is left. Our calculator visualizes this decomposition with a division breakdown showing dividend, divisor, quotient, and remainder as distinct colored elements.

Clock Arithmetic: Modulo Made Visual

The most intuitive model for modular arithmetic is a clock. A 12-hour clock performs mod 12: after 12, numbers wrap back to 0 (or 12). If it is 10 o’clock and you wait 5 hours, it becomes 3 o’clock: (10 + 5) mod 12 = 15 mod 12 = 3. This "wrapping around" behavior is the essence of modular arithmetic. Our clock visualization draws a circular dial with b positions, highlighting where the number a lands. Days of the week use mod 7: Wednesday (3) plus 10 days = Saturday (6), because (3 + 10) mod 7 = 13 mod 7 = 6.

a mod b = r, where a = q × b + r and 0 ≤ r < b

17 mod 5 = 2 (because 17 = 3×5 + 2)
25 mod 7 = 4 (because 25 = 3×7 + 4)
100 mod 3 = 1 (because 100 = 33×3 + 1)

Properties:
(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 mod 1 = 0 (always)
a mod a = 0 (always)

Congruence: a ≡ b (mod n) if n | (a - b)
17 ≡ 2 (mod 5) because 5 | (17 - 2)

Modular Arithmetic Properties

Modular arithmetic preserves addition and multiplication: (a + b) mod n = ((a mod n) + (b mod n)) mod n, and similarly for multiplication. This means you can reduce numbers before computing, which is essential for working with very large numbers in cryptography. However, division does not work the same way — modular division requires finding the modular multiplicative inverse. If a × x ≡ 1 (mod n), then x is the inverse of a modulo n. The inverse exists only when gcd(a, n) = 1 (a and n are coprime). This inverse is computed using the Extended Euclidean Algorithm.

Congruence Classes

Two numbers are congruent modulo n if they have the same remainder when divided by n. Written a ≡ b (mod n), it means n divides (a − b). For example, 17 ≡ 2 (mod 5) because 5 divides 15. All integers that are congruent mod n form a congruence class (or residue class). Mod 5 has five classes: {0,5,10,15,...}, {1,6,11,16,...}, {2,7,12,17,...}, {3,8,13,18,...}, {4,9,14,19,...}. These classes form a complete number system called ℤ/nℤ, with well-defined addition and multiplication. Our calculator shows the first 15 members of the input’s congruence class.

Modulo in Programming

Every programming language has a modulo operator (% in C/Java/Python/JS, mod in Pascal/VB). Common uses include: even/odd check: n % 2 == 0 means even. Wrapping indices: circular arrays use i % length. Hash functions: hash(key) % table_size determines bucket. Time calculations: total_seconds % 60 gives seconds, (total_seconds / 60) % 60 gives minutes. Pagination: determine which page an item belongs to. Alternating patterns: i % 2 alternates between 0 and 1 for striped tables. The modulo operator is one of the most frequently used operations in practical programming.

Modular Arithmetic in Cryptography

Modern encryption relies heavily on modular arithmetic with extremely large numbers (hundreds of digits). RSA encryption works by computing c = m^e mod n, where m is the message, e is the public exponent, and n is the product of two large primes. Decryption uses m = c^d mod n with the private exponent d. The security relies on the difficulty of factoring n. Diffie-Hellman key exchange uses modular exponentiation: A = g^a mod p, where g and p are public but a is private. Even knowing A, g, and p, finding a (the discrete logarithm problem) is computationally infeasible for large p. This is the foundation of secure internet communication (HTTPS, SSH, VPN).

How to Use This Calculator

Enter the dividend (a) and divisor (b). The calculator computes a mod b, showing the remainder, quotient, and the complete equation a = q × b + r. The clock visualization wraps a around a circular dial of b positions. The number line shows jumps of b size from 0, highlighting where a falls. The modular arithmetic table shows a mod 2 through mod 12 for quick reference. The congruence class display lists numbers equivalent to the result, demonstrating the periodic wrapping pattern. Step-by-step solution walks through the division and verification.

Modulo in Everyday Life

You use modular arithmetic daily without realizing it. Clocks: hours wrap mod 12 or mod 24. Calendars: days of the week cycle mod 7, months mod 12. Odometers: wrap mod 1,000,000 (or 100,000). Music: notes cycle mod 12 (chromatic scale), so C and C-an-octave-higher are "the same" mod 12. Circular intersections: roundabouts are physical modular arithmetic. Check digits: ISBN uses mod 11, credit cards use Luhn algorithm (mod 10), Social Security numbers use mod-based validation. These everyday applications demonstrate why modular arithmetic is one of the most practical mathematical concepts.

Math Note
The divisor b must be a positive integer (b > 0). For negative dividends, this calculator uses the mathematical convention where the remainder is always non-negative (0 ≤ r < b), which may differ from some programming languages where the sign of the remainder follows the dividend.

Frequently Asked Questions

What is modulo?
Remainder after division. 17 mod 5 = 2 because 17 = 3×5 + 2. The "left over" after dividing evenly.
How is mod used in programming?
% operator. Even/odd: n%2. Wrapping: i%length. Time: seconds%60. Hash tables: hash%size. Extremely common.
What is clock arithmetic?
Mod 12 on a clock: 10+5=3 o’clock (15 mod 12=3). Numbers wrap around. Days: mod 7. Months: mod 12.
Mod in cryptography?
RSA: c=m^e mod n. Security from difficulty of reversing modular exponentiation with huge primes. All HTTPS uses this.
What is congruence?
a ≡ b (mod n) means same remainder. 17 ≡ 2 (mod 5). They’re in the same residue class. Foundation of number theory.