Congruence Modulo

Solve modular arithmetic problems instantly. Calculate (a mod n) with this free Congruence Modulo Calculator.

Result

What is Congruence Modulo?

In modular arithmetic, two numbers aa and bb are said to be congruent modulo nn if their difference (ab)(a - b) is an integer multiple of nn. This is written as:

ab(modn)a \equiv b \pmod{n}

This implies that aa and bb have the same remainder when divided by nn.

Understanding the Definition

The modulo operator (often denoted as % in programming) finds the remainder of division.

  • a(modn)a \pmod{n} is the remainder when aa is divided by nn.
  • If a%n=b%na \% n = b \% n, then ab(modn)a \equiv b \pmod{n}.

Example: Is 2611(mod5)26 \equiv 11 \pmod{5}?

  • 26÷5=526 \div 5 = 5 with remainder 1.
  • 11÷5=211 \div 5 = 2 with remainder 1.
  • Since the remainders are the same (1), the statement is TRUE.

Alternatively, check the difference:

  • 2611=1526 - 11 = 15
  • Is 15 a multiple of 5? Yes (15=3×515 = 3 \times 5).
  • Therefore, they are congruent.

Properties of Modular Arithmetic

  1. Reflexive: aa(modn)a \equiv a \pmod{n}
  2. Symmetric: If ab(modn)a \equiv b \pmod{n}, then ba(modn)b \equiv a \pmod{n}
  3. Transitive: If ab(modn)a \equiv b \pmod{n} and bc(modn)b \equiv c \pmod{n}, then ac(modn)a \equiv c \pmod{n}
  4. Addition: If aba \equiv b and cdc \equiv d, then a+cb+d(modn)a+c \equiv b+d \pmod{n}
  5. Multiplication: If aba \equiv b and cdc \equiv d, then acbd(modn)ac \equiv bd \pmod{n}

Real-World Applications

  • 12-Hour Clock: Timekeeping is a classic example of modulo 12 arithmetic. If it is 9:00 now, 5 hours later it will be 2:00 (not 14:00). We calculate (9+5)2(mod12)(9 + 5) \equiv 2 \pmod{12}.
  • Cryptography: Modular arithmetic is the backbone of modern encryption algorithm, including RSA, where operations are performed modulo a very large product of prime numbers.
  • Computer Science: Used in hash functions, checksums, and generating random numbers.
  • Calendars: Determining the day of the week (modulo 7).

Frequently Asked Questions

Q: Can the modulus nn be negative? A: In standard mathematical definitions, the modulus nn is typically a positive integer greater than 1. However, some programming languages handle negative moduli differently.

Q: What is the difference between Congruence and Equality? A: Equality (==) means two numbers are the exact same value (e.g., 14=1414 = 14). Congruence (\equiv) means they are in the same equivalence class modulo nn (e.g., 142(mod12)14 \equiv 2 \pmod{12}), even though 14214 \neq 2.

Q: How do I find the smallest positive representative? A: To find the smallest positive xx such that xa(modn)x \equiv a \pmod{n}, simply perform the modulo operation a%na \% n. (Note: for negative aa, you may need to add nn to the result until it is positive).