Modular Arithmetic Calculator
Modulo, modular exponentiation, and inverse.
Result
2
17 mod 5
Uses BigInt so it handles arbitrarily large numbers. Exponentiation runs square-and-multiply, inverse uses the extended Euclidean algorithm.
About
Compute a mod n, (a^b) mod n efficiently, and the modular inverse of a mod n (if it exists). Used in cryptography, hashing, and number theory.
How to use
- Pick the operation.
- Enter the inputs.
- See the result.
FAQ
When does the modular inverse not exist?+
The inverse of a mod n exists only if gcd(a, n) = 1. If they share a factor, no inverse.
Why use modular exponentiation?+
Computing 2^1000 mod 17 directly overflows. The fast modular exponentiation algorithm keeps numbers small the whole way.