Modulo Calculator

Compute the modulo operation (remainder of an integer division)

Compute modulo

What is the modulo operation?

The modulo operation computes the remainder of a division. For a mod b, a is divided by b and the remaining remainder is returned.

11 mod 4 = ?
Enter numbers
Number to be divided
÷
Number to divide by
Calculation result
Quotient:
Modulo:
Calculation: Dividend ÷ Divisor = Quotient remainder Modulo

Modulo Info

Properties

Modulo: Remainder of an integer division

mod % remainder

Range: 0 ≤ (a mod b) < |b| for b ≠ 0
Notation: a mod b or a % b

Quick examples
11 mod 4 = 3 (11 ÷ 4 = 2 remainder 3)
17 mod 5 = 2 (17 ÷ 5 = 3 remainder 2)
8 mod 3 = 2 (8 ÷ 3 = 2 remainder 2)
10 mod 2 = 0 (10 ÷ 2 = 5 remainder 0)

Formulas and definitions of the modulo operation

Definition
\[a \bmod b = r \text{, where } a = q \cdot b + r\] \[0 \leq r < |b|\]

r is the unique remainder of dividing a by b

Division algorithm
\[a = b \cdot q + r\] \[\text{where } q = \lfloor a/b \rfloor\]

Euclidean division algorithm with quotient q and remainder r

Properties
\[(a + b) \bmod n = ((a \bmod n) + (b \bmod n)) \bmod n\] \[(a \cdot b) \bmod n = ((a \bmod n) \cdot (b \bmod n)) \bmod n\]

Distributivity of the modulo operation

Negative numbers
\[(-a) \bmod b = b - (a \bmod b) \text{ for } a \bmod b \neq 0\] \[(-a) \bmod b = 0 \text{ for } a \bmod b = 0\]

Handling of negative dividends

Congruence
\[a \equiv b \pmod{n} \Leftrightarrow a \bmod n = b \bmod n\]

Equivalence of modulo and congruence

Special cases
\[a \bmod 1 = 0 \text{ for all } a\] \[a \bmod a = 0 \text{ for all } a \neq 0\] \[0 \bmod b = 0 \text{ for all } b \neq 0\]

Important special cases of the modulo operation

Example calculations with modulo

Example 1: 11 mod 4
Dividend: 11 Divisor: 4
Step 1: Perform division
11 ÷ 4 = 2 remainder 3
Verification: 2 × 4 + 3 = 11 ✓
Result: 11 mod 4 = 3
\[11 = 4 \times 2 + 3\] \[11 \bmod 4 = 3\]
Example 2: 17 mod 5
Dividend: 17 Divisor: 5
Step 1: Perform division
17 ÷ 5 = 3 remainder 2
Verification: 3 × 5 + 2 = 17 ✓
Result: 17 mod 5 = 2
\[17 = 5 \times 3 + 2\] \[17 \bmod 5 = 2\]
Example 3: Negative number (-7 mod 3)
Dividend: -7 Divisor: 3
Step 1: Positive division: 7 ÷ 3 = 2 remainder 1
Step 2: For negatives: 3 - 1 = 2
Result: -7 mod 3 = 2
\[-7 = 3 \times (-3) + 2\] \[(-7) \bmod 3 = 2\]
Example 4: Perfect division (10 mod 2)
Dividend: 10 Divisor: 2
Step 1: Perform division
10 ÷ 2 = 5 remainder 0
Result: 10 mod 2 = 0 (divisible)
\[10 = 2 \times 5 + 0\] \[10 \bmod 2 = 0\]
Modulo properties demonstrated
Remainder ≥ 0
Always non-negative
Remainder < Divisor
Smaller than the divisor
Unique
Exactly one remainder possible
Cyclic
Repeating pattern

The modulo operation follows mathematical laws

Applications of the modulo operation

The modulo operation has many practical and theoretical applications:

Programming & computer science
  • Hash functions and hash tables
  • Pseudo-random number generators
  • Circular buffers and ring buffers
  • Array indexing (wrap-around)
Cryptography & security
  • RSA encryption
  • Modular arithmetic
  • Diffie-Hellman key exchange
  • Digital signatures
Timekeeping & cycles
  • Compute weekdays (mod 7)
  • 12-hour vs 24-hour format
  • Calendar calculations
  • Periodic events
Mathematics & number theory
  • Congruence arithmetic
  • Divisibility tests
  • Chinese remainder theorem
  • Discrete mathematics

The modulo operation: Foundation of number theory

The modulo operation is far more than just a "remainder of a division." It forms the foundation of modern number theory and enables elegant solutions to complex problems. From simple checks for even/odd numbers to highly secure encryption schemes, the modulo operation shows how basic mathematical concepts find practical applications in the digital world. It defines equivalence classes and creates algebraic structures that are indispensable in cryptography, computer science and discrete mathematics.

Properties
  • 0 ≤ (a mod n) < n for n > 0
  • Distributivity over addition/multiplication
  • Defines equivalence relations
  • Periodic/cyclic behavior
Significance
  • Basis of congruence arithmetic
  • Core of cryptographic schemes
  • Enables efficient algorithms
  • Structures discrete mathematics
Applications
  • Cryptography and IT security
  • Hash functions and data structures
  • Time and calendar calculations
  • Random numbers and simulations
Summary

The modulo operation links elementary arithmetic with cutting-edge applications. What begins as a simple "remainder of a division" becomes a powerful tool of discrete mathematics. From detecting even numbers (n mod 2 = 0) to RSA encryption, the modulo operation demonstrates how mathematical elegance and practical utility harmonize. It exemplifies how simple concepts lead to complex and secure systems.