Modular Arithmetic Calculator
Compute modular operations with fast exponentiation, find modular inverses using the extended Euclidean algorithm, solve systems of congruences via the Chinese Remainder Theorem, and explore clock arithmetic on an interactive number circle.
Inputs
Results
Fast Exponentiation: 7^10 mod 12
Binary exponentiation computes in multiplications by repeated squaring.
Binary of 10: 1010 — each bit corresponds to a squaring step.
Clock Diagram (a + b) mod 12
Reference Guide
Modular Arithmetic
Two integers are congruent modulo if they differ by a multiple of . We write when .
The four basic operations carry through: addition, subtraction, and multiplication all respect congruences. Fast exponentiation uses binary squaring to compute in steps.
Modular Inverse
The modular inverse of modulo is the value such that . It exists if and only if .
The extended Euclidean algorithm finds integers such that , giving as the inverse. This runs in time.
Chinese Remainder Theorem
If are pairwise coprime, then the system of congruences has a unique solution modulo .
The solution is built iteratively: merge two congruences at a time using the extended Euclidean algorithm, doubling the modulus at each step.
Applications in Cryptography
Modular arithmetic underpins modern cryptography. In RSA, encryption is and decryption uses , where is a product of large primes.
Euler's totient counts integers coprime to . For RSA: . The key insight is Euler's theorem: for .
Caesar and affine ciphers use (mod 26). The CRT helps reconstruct large integers from their residues, used in efficient multi-prime RSA.