Explore modular arithmetic with comprehensive calculations, congruences, and number theory operations. Perfect for cryptography and discrete mathematics.
Select an operation and enter values to see results
Detailed steps will appear here after calculation
Properties will be shown after calculation
Modular arithmetic is a system of arithmetic for integers where numbers "wrap around" after reaching a certain value called the modulus.
Two integers a and b are congruent modulo m if their difference is divisible by m.
Notation: a ≡ b (mod m)
Example: 17 ≡ 5 (mod 12) because 17 - 5 = 12
The modulo operation finds the remainder after division.
Notation: a mod m = r
Example: 17 mod 12 = 5
All integers congruent to each other modulo m form an equivalence class.
Example: [2]₅ = {..., -8, -3, 2, 7, 12, ...}
A complete residue system modulo m is a set of m integers, no two congruent modulo m.
Example: {0, 1, 2, 3, 4} is a complete residue system mod 5
The modular inverse of a modulo m is a number x such that (a × x) ≡ 1 (mod m).
If m₁, m₂, ..., mₖ are pairwise coprime, then the system of congruences:
has a unique solution modulo M = m₁ × m₂ × ... × mₖ.
If gcd(a, n) = 1, then a^φ(n) ≡ 1 (mod n), where φ(n) is Euler's totient function.
If p is prime and gcd(a, p) = 1, then a^(p-1) ≡ 1 (mod p).
Computes a^b mod m efficiently using binary representation of the exponent:
Finds integers x and y such that ax + by = gcd(a, b):