Free Modulo Calculator – Compute Remainder & Modulo Instantly

Calculate modulus operations, congruence, and division remainders with detailed solutions.

Modulo Calculator

Enter numbers and select calculation type

🔢 Modulo
Congruence
+−× Modular Arithmetic
Modular Inverse
Modular Exponentiation
🧩 System of Congruences

Calculation Results

TXT
CSV
JSON
Print
-
Result
-
Modulus
-
Type
-
Status

Recent Calculations

What is Modulo Operation?

Modulo operation finds the remainder after division of one number by another. For two numbers a and n, a mod n is the remainder when a is divided by n.

Key Concepts:

  • Dividend (a): The number being divided
  • Divisor (n): The number by which we divide
  • Quotient (q): The result of integer division
  • Remainder (r): The result of modulo operation (0 ≤ r < n)
  • Equation: a = n × q + r where 0 ≤ r < n

Basic Modulo Operation

The modulo operation finds the remainder after division.

17 ÷ 5 = 3 with remainder 2
So 17 mod 5 = 2

Negative Modulo

Negative numbers follow the Euclidean definition for consistency.

-17 mod 5 = ?
-17 + 5×4 = -17 + 20 = 3
So -17 mod 5 = 3

Modulo Properties

Modulo operation has several important mathematical 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

Congruence Relations

Modular congruence is a fundamental concept in number theory with applications in cryptography and computer science.

Congruence: Two numbers a and b are congruent modulo n if they have the same remainder when divided by n. Written as a ≡ b (mod n).

Congruence Definition

a ≡ b (mod n) if and only if n divides (a - b).

17 ≡ 2 (mod 5) because
17 - 2 = 15, and 5 divides 15

Congruence Classes

Numbers with the same remainder form equivalence classes.

Modulo 5 classes:
[0] = {..., -10, -5, 0, 5, 10, ...}
[1] = {..., -9, -4, 1, 6, 11, ...}
[2] = {..., -8, -3, 2, 7, 12, ...}

Congruence Properties

Congruence relations behave similarly to equations.

If a ≡ b (mod n) and c ≡ d (mod n), then:
a + c ≡ b + d (mod n)
a × c ≡ b × d (mod n)

Solving Congruences

Linear congruences can be solved using modular inverses.

Solve: 3x ≡ 4 (mod 7)
x ≡ 3⁻¹ × 4 (mod 7)
Since 3×5 ≡ 1 (mod 7), x ≡ 5×4 ≡ 6 (mod 7)

Modular Arithmetic

Arithmetic operations performed within a fixed modulus have unique properties and applications.

Modular arithmetic is a system of arithmetic for integers where numbers "wrap around" upon reaching a certain value—the modulus.

Addition Modulo n

Addition is performed normally, then reduced modulo n.

(17 + 8) mod 5
25 mod 5 = 0
Or: (2 + 3) mod 5 = 5 mod 5 = 0

Subtraction Modulo n

Subtraction may require adding multiples of n for negative results.

(3 - 8) mod 5
-5 mod 5 = 0
Or: (3 + 2) mod 5 = 5 mod 5 = 0

Multiplication Modulo n

Multiply then take modulo, or use distributive property.

(17 × 3) mod 5
51 mod 5 = 1
Or: (2 × 3) mod 5 = 6 mod 5 = 1

Division Modulo n

Division is multiplication by the modular inverse.

(7 ÷ 3) mod 11
3⁻¹ mod 11 = 4 (since 3×4=12≡1)
7 × 4 = 28 ≡ 6 (mod 11)

Exponentiation Modulo n

Repeated multiplication, optimized with exponentiation by squaring.

3⁴ mod 7
3² = 9 ≡ 2 mod 7
3⁴ = (3²)² ≡ 2² = 4 mod 7

Modular Inverse

The number that when multiplied gives 1 modulo n.

Inverse of 3 mod 11:
3 × 4 = 12 ≡ 1 mod 11
So 3⁻¹ ≡ 4 mod 11
Fermat's Little Theorem:
If p is prime and a is not divisible by p, then a^(p-1) ≡ 1 (mod p)

Real-World Applications of Modulo Operations

Modulo arithmetic has numerous practical applications in various fields:

Cryptography

  • RSA encryption algorithm
  • Diffie-Hellman key exchange
  • Digital signatures
  • Hash functions

Computer Science

  • Hash tables and data structures
  • Checksums and error detection
  • Random number generation
  • Memory addressing

Time Calculations

  • Clock arithmetic (12-hour and 24-hour)
  • Calendar calculations
  • Scheduling and timing systems
  • Time zone conversions

Mathematics

  • Number theory proofs
  • Diophantine equations
  • Group theory and abstract algebra
  • Cryptanalysis

Engineering

  • Signal processing
  • Error-correcting codes
  • Computer graphics
  • Digital circuit design

Everyday Life

  • ISBN and UPC check digits
  • Credit card number validation
  • Game development
  • Music theory and rhythm

Solved Examples

Step-by-step solutions to common modulo problems:

Example 1: Basic Modulo
Calculate 23 mod 7.
1. Divide 23 by 7: 23 ÷ 7 = 3 with remainder
2. 7 × 3 = 21
3. 23 - 21 = 2
4. So 23 mod 7 = 2
Result: 2
Example 2: Negative Modulo
Calculate -17 mod 5.
1. Add multiples of 5 until positive
2. -17 + 5×4 = -17 + 20 = 3
3. Since 3 is between 0 and 5
4. So -17 mod 5 = 3
Result: 3
Example 3: Congruence
Check if 42 ≡ 12 (mod 10).
1. Calculate 42 mod 10 = 2
2. Calculate 12 mod 10 = 2
3. Both have the same remainder
4. So 42 ≡ 12 (mod 10)
Result: Congruent
Example 4: Modular Inverse
Find the inverse of 3 modulo 11.
1. We need x such that 3x ≡ 1 (mod 11)
2. Try x=4: 3×4=12≡1 (mod 11)
3. So the inverse is 4
Result: 4
Example 5: Modular Exponentiation
Calculate 2¹⁰ mod 7.
1. 2² = 4 mod 7
2. 2⁴ = (2²)² = 4² = 16 ≡ 2 mod 7
3. 2⁸ = (2⁴)² = 2² = 4 mod 7
4. 2¹⁰ = 2⁸ × 2² = 4 × 4 = 16 ≡ 2 mod 7
Result: 2
Example 6: System of Congruences
Solve: x ≡ 2 (mod 3), x ≡ 3 (mod 5)
1. Numbers that ≡2 mod3: 2,5,8,11,14,17,...
2. Numbers that ≡3 mod5: 3,8,13,18,23,...
3. Common solution: x=8
4. General solution: x ≡ 8 (mod 15)
Result: x ≡ 8 (mod 15)

Practice Problems

Test your understanding with these practice problems:

Problem 1: Calculate 47 mod 6.

Solution:

47 ÷ 6 = 7 with remainder 5 (6×7=42, 47-42=5)

So 47 mod 6 = 5

Problem 2: Calculate -13 mod 8.

Solution:

-13 + 8×2 = -13 + 16 = 3

So -13 mod 8 = 3

Problem 3: Is 81 ≡ 21 (mod 10)?

Solution:

81 mod 10 = 1

21 mod 10 = 1

Both have the same remainder, so 81 ≡ 21 (mod 10)

Problem 4: Find the inverse of 5 modulo 7.

Solution:

We need x such that 5x ≡ 1 (mod 7)

5×3 = 15 ≡ 1 (mod 7)

So the inverse is 3

Problem 5: Solve the system: x ≡ 1 (mod 2), x ≡ 2 (mod 3)

Solution:

Numbers that ≡1 mod2: 1,3,5,7,9,11,...

Numbers that ≡2 mod3: 2,5,8,11,14,...

Common solutions: 5, 11, 17,...

General solution: x ≡ 5 (mod 6)

How to Calculate Modulo Step-by-Step

Follow this systematic approach to perform modulo operations:

1

Understand the Operation

Modulo finds the remainder after division. a mod n is the remainder when a is divided by n.

Example: 17 mod 5
2

Perform Division

Divide the dividend by the divisor using integer division.

17 ÷ 5 = 3 (integer division)
3

Calculate Remainder

Subtract the product from the original number to find the remainder.

17 - (5 × 3) = 17 - 15 = 2
4

Handle Negative Numbers

For negative dividends, add multiples of the divisor until positive.

-17 mod 5: -17 + 20 = 3
5

Verify Result

Ensure the remainder is between 0 and n-1.

2 is between 0 and 4 ✓
6

Check Congruence

For congruence, check if two numbers have the same remainder.

17 mod 5 = 2, 22 mod 5 = 2
So 17 ≡ 22 (mod 5)

Pro Tips for Modulo Calculations

  • Use properties: (a + b) mod n = [(a mod n) + (b mod n)] mod n
  • Negative numbers: a mod n is always between 0 and n-1
  • Modular inverse: a⁻¹ mod n exists if gcd(a, n) = 1
  • Exponentiation: Use exponentiation by squaring for large powers
  • Chinese Remainder Theorem: For solving systems of congruences

Modulo Calculator FAQs – Mod, Remainder & Modular Arithmetic Explained

Learn everything about modulo operations, remainders, congruence, and modular arithmetic.

What is a modulo operation?
The modulo operation finds the remainder after dividing one number by another. For example, 17 mod 5 = 2.
What is the difference between modulo and remainder?
For positive numbers, modulo and remainder are the same. For negative numbers, modulo always returns a value between 0 and n−1, while remainder may differ depending on programming language.
Can modulo be negative?
No, in mathematics modulo results are always non-negative. Negative values are adjusted into the range 0 to n−1.
What does a ≡ b (mod n) mean?
It means a and b have the same remainder when divided by n, or that n divides (a − b). This is called modular congruence.
How do you calculate a mod n?
Divide a by n and take the remainder. Alternatively, use a mod n = a − n × floor(a/n).
What is modular arithmetic?
Modular arithmetic is a system of arithmetic for integers where numbers wrap around after reaching a certain value (modulus).
Where is modulo used in real life?
Modulo is used in cryptography, programming, clocks, hashing, cyclic patterns, and computer algorithms.
What is modular inverse?
A modular inverse of a number a modulo n is a number x such that a × x ≡ 1 (mod n), and it exists only if gcd(a, n) = 1.
What is modular exponentiation?
It is the process of finding (a^b mod n) efficiently, widely used in cryptography and algorithms.
How does modulo work with negative numbers?
Negative numbers are adjusted by adding multiples of n until the result is within the standard range of 0 to n−1.
What is the Chinese Remainder Theorem?
It states that systems of congruences with coprime moduli have a unique solution modulo the product of the moduli.
Is modulo the same as division?
No, modulo gives only the remainder of division, not the quotient.
What is mod in programming?
In programming, mod (%) returns the remainder of division, though behavior may differ for negative numbers.
Can this modulo calculator handle large numbers?
Yes, advanced algorithms allow handling of large integers quickly and accurately.