Modulo: Remainder After Division
a mod n is the remainder when a is divided by n. Euclidean definition: a = n×q + r with 0 ≤ r < |n|. Used in clock arithmetic, hashing, and cryptography.
Did our AI summary help? Let us know.
Euclidean modulo: remainder always non-negative, 0 ≤ r < |n|. Clock arithmetic: 14 mod 12 = 2 (2 o'clock). Hash functions: key mod table_size distributes entries.
Ready to run the numbers?
Why: Modulo is fundamental in cryptography, hashing, and cyclic systems. Clock arithmetic: 14 mod 12 = 2. Even/odd: n mod 2. Day of week: date mod 7.
How: Euclidean: a = n×q + r with 0 ≤ r < |n|. For negative a, r is always non-negative. Programming languages differ (Python vs C vs JS).
Run the calculator when you are ready.
Enter Values
Division Equation Components
Clock Arithmetic (mod 5)
📐 Step-by-Step Breakdown
For educational and informational purposes only. Verify with a qualified professional.
🧮 Fascinating Math Facts
a mod n = remainder when a ÷ n
— Modular arithmetic
Clock: 14 mod 12 = 2
— Cyclic systems
📋 Key Takeaways
- • a mod n is the remainder when a is divided by n
- • Result is always 0 ≤ r < |n| (Euclidean definition)
- • Clock arithmetic: 12-hour clock uses mod 12; days use mod 7
- • Even/odd: n mod 2 = 0 means even, 1 means odd
- • For negative a: Euclidean mod gives non-negative remainder
💡 Did You Know?
📖 How It Works
Given a (dividend) and n (divisor), we find q (quotient) and r (remainder) such that a = n × q + r with 0 ≤ r < |n|. The remainder r is a mod n. For negative a, we use the Euclidean definition so r stays non-negative. JavaScript's % operator can return negative remainders; use ((a % n) + n) % n for Euclidean modulo.
📝 Worked Example: 17 mod 5
Step 1: Divide 17 by 5: 17 ÷ 5 = 3 remainder 2
Step 2: Quotient q = ⌊17/5⌋ = 3
Step 3: Remainder r = 17 − 5×3 = 2
Result: 17 mod 5 = 2
Equation: 17 = 5 × 3 + 2
Verification: 5 × 3 + 2 = 17 ✓
🚀 Real-World Applications
🕐 Time & Clocks
12-hour clock (mod 12), 24-hour to 12-hour conversion.
📅 Calendars
Day of week (mod 7), cyclic date calculations.
💻 Hash Tables
Distributing keys across buckets: hash mod table_size.
🔐 Cryptography
RSA, Diffie-Hellman use modular exponentiation.
📊 Check Digits
ISBN, credit cards use mod 10 or mod 11.
🎲 Random Numbers
LCRNG: next = (a×prev + c) mod m.
⚠️ Common Mistakes to Avoid
- Using JavaScript % for negative numbers: -7 % 3 = -1 in JS; Euclidean gives 2.
- Division by zero: a mod 0 is undefined.
- Confusing quotient and remainder: 17 ÷ 5 gives q=3, r=2 — not q=3.4.
- Forgetting floor: Quotient uses floor division, not truncation for negatives.
- Mod vs remainder: Truncated remainder can be negative; Euclidean mod is always 0 ≤ r < |n|.
🎯 Expert Tips
💡 Programming
JavaScript % can give negative remainders. Use ((a % n) + n) % n for Euclidean modulo.
💡 Power of 2
a mod 2^k = last k bits of a. Fast: use bitwise AND with (2^k - 1).
💡 Day of Week
n mod 7 gives day. 100 days from Sunday = 100 mod 7 = 2 (Tuesday).
💡 Verify
Always check: a = n × q + r. Quotient × divisor + remainder = dividend.
📊 Reference Table
| Expression | Result | Equation |
|---|---|---|
| 17 mod 5 | 2 | 17 = 5×3 + 2 |
| -7 mod 3 | 2 | -7 = 3×(-3) + 2 |
| 100 mod 7 | 2 | 100 = 7×14 + 2 |
| 24 mod 12 | 0 | 24 = 12×2 + 0 |
| 8 mod 2 | 0 | 8 is even |
📐 Quick Reference
🎓 Practice Problems
❓ FAQ
What is modulo?
a mod n is the remainder when a is divided by n. E.g. 17 mod 5 = 2 because 17 = 5×3 + 2.
How does negative modulo work?
Euclidean definition: remainder is always 0 ≤ r < |n|. So -7 mod 3 = 2.
What is clock arithmetic?
Modular arithmetic. 12-hour clock uses mod 12: 14 mod 12 = 2.
Why is modulo used in hash functions?
hash(key) mod table_size ensures the index stays within array bounds.
What is the difference between mod and remainder?
Remainder can be negative (truncated); Euclidean mod is always 0 ≤ r < |n|.
Can the divisor be negative?
Yes. We use |n| so the remainder stays in [0, |n|).
How do I verify my result?
Check: dividend = divisor × quotient + remainder. E.g. 17 = 5×3 + 2 ✓
📌 Summary
Modulo returns the remainder of division. The Euclidean definition ensures 0 ≤ r < |n| for any dividend. It powers clock arithmetic, hash tables, cryptography, and check digits. Always verify with a = n×q + r.
✅ Verification Tip
Plug your result into the division equation: dividend = divisor × quotient + remainder. If it holds, your modulo is correct.
🔗 Next Steps
Explore the Remainder Calculator for different division methods (Euclidean, truncated, floored), the Power Mod Calculator for modular exponentiation, or the Inverse Modulo Calculator for finding modular inverses.
⚠️ Disclaimer: Uses Euclidean (mathematical) modulo. Programming languages may differ (Python vs C vs JavaScript). For very large integers, JavaScript number precision may be limited.
Related Calculators
Chinese Remainder Theorem Calculator
Solve systems of congruence equations x ≡ a_i (mod m_i) using the Chinese Remainder Theorem. Step-by-step solution with multiple moduli, modular inverse, and...
MathematicsDivision Calculator
Perform division with quotient and remainder. Get decimal results, fraction form, and step-by-step long division. Calculate a ÷ b for integers and decimals...
MathematicsInteger Division Calculator
Calculate quotient and remainder for integer division using the Euclidean division theorem. a = b×q + r where 0 ≤ r < |b|. Step-by-step solutions for time...
MathematicsMultiplicative Inverse Modulo Calculator
Find the multiplicative inverse of a modulo m: a×x ≡ 1 (mod m). Uses the Extended Euclidean Algorithm with step-by-step trace. Applications in cryptography (RSA, Diffie-Hellman), linear congruences, and Chinese Remainder Theorem. Verify with Fermat's Little Theorem for prime moduli.
MathematicsRemainder Calculator
Calculate quotient and remainder: a = b×q + r. Euclidean (non-negative r), truncated, floored division. Verify results, handle negative dividend...
MathematicsAbsolute Change Calculator
Calculate absolute and relative change between two values. Get direction (increase/decrease), percentage impact, and step-by-step solutions. Simple mode for...
Mathematics