NUMBER THEORYArithmeticMathematics Calculator
%

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.

Concept Fundamentals
Remainder r
a mod n
q = ⌊a÷n⌋
Quotient
0 ≤ r < |n|
Range
12 mod 12 = 0
Clock

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.

Key quantities
Remainder r
a mod n
Key relation
q = ⌊a÷n⌋
Quotient
Key relation
0 ≤ r < |n|
Range
Key relation
12 mod 12 = 0
Clock
Key relation

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).

Euclidean modulo: remainder always non-negative, 0 ≤ r < |n|.Clock arithmetic: 14 mod 12 = 2 (2 o'clock).

Run the calculator when you are ready.

Calculate ModuloEnter dividend and divisor

Enter Values

modulo.sh
CALCULATED
$ mod --a=17 --n=5
Remainder
2
Quotient
3
(-a) mod n
3
Equation
17 = 5 × 3 + 2
Modulo Calculator
17 mod 5 = 2
17 = 5 × 3 + 2
numbervibe.com
Share:

Division Equation Components

Clock Arithmetic (mod 5)

📐 Step-by-Step Breakdown

INPUTS
Dividend (a)
17
Divisor (n)
5
CALCULATION
Quotient (q)
3
⌊17 ÷ 5⌋
Remainder (r)
2
a mod n = 2
Equation
17 = 5 × 3 + 2
a = n imes q + r
EXTRA
(-a) mod n
3

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?

🕐A 12-hour clock is modulo 12. 15:00 is 3 o'clock because 15 mod 12 = 3Source: Clock Arithmetic
📅Day of week: 365 mod 7 = 1, so 365 days from now is one day laterSource: Calendar Systems
💻Hash tables use modulo: hash(key) mod bucket_countSource: Computer Science
🔐RSA and crypto rely on modular exponentiationSource: Cryptography
⚖️Even/odd: n mod 2 = 0 means even, 1 means oddSource: Parity
📐Euclidean modulo: -7 mod 3 = 2, not -1 (truncated)Source: Number Theory

📖 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

ExpressionResultEquation
17 mod 5217 = 5×3 + 2
-7 mod 32-7 = 3×(-3) + 2
100 mod 72100 = 7×14 + 2
24 mod 12024 = 12×2 + 0
8 mod 208 is even

📐 Quick Reference

0
Minimum remainder
|n|-1
Maximum remainder
7
Days in week
12
Clock modulus

🎓 Practice Problems

23 mod 5 → Answer: 3
-11 mod 4 → Answer: 1
100 mod 7 → Answer: 2 (Tuesday)
256 mod 16 → Answer: 0

❓ 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.

👈 START HERE
⬅️Jump in and explore the concept!
AI

Related Calculators