Interactive Modular Arithmetic & Modulo Calculator
Calculate modulo, fast modular exponentiation (A^B mod M), and modular multiplicative inverse.
The fascinating world of numbers
Calculate modulo, fast modular exponentiation (A^B mod M), and modular multiplicative inverse.
Calculate modulo, fast modular exponentiation (A^B mod M), and modular multiplicative inverse.
Modular arithmetic (often called "clock arithmetic") deals with integers where numbers "wrap around" upon reaching a given modulus. It forms the mathematical backbone of modern cryptography, including RSA encryption and Diffie-Hellman key exchange.
A × X ≡ 1 (mod M)
An inverse X exists if and only if A and M are coprime (i.e. GCF(A, M) = 1). It is found using the Extended Euclidean Algorithm.
Using fast modular exponentiation: 7¹³ mod 19 = 11. Furthermore, the modular inverse of 7 mod 19 is 11, because 7 × 11 = 77 = 4 × 19 + 1.
In mathematics, the modulo operation yields a positive remainder in [0, M−1]. Adding 12 to −5 wraps around to positive 7.
A modular inverse fails to exist whenever GCF(A, M) > 1, because no multiple of A can differ from a multiple of M by 1.