Modular Arithmetic Calculator
Calculate mod, modular addition, subtraction, multiplication, exponentiation, and modular inverse for any integers.
Inputs
Result
—
—
Step-by-step
Operation Reference
| Operation | Formula | Example (N=7) |
|---|---|---|
| Mod | A mod N | 17 mod 7 = 3 |
| Add | (A+B) mod N | (5+4) mod 7 = 2 |
| Subtract | (A−B) mod N | (2−5) mod 7 = 4 |
| Multiply | (A×B) mod N | (3×5) mod 7 = 1 |
| Power | A^B mod N | 3^4 mod 7 = 4 |
| Inverse | A⁻¹ mod N | 3⁻¹ mod 7 = 5 |
Copied!
Summary
Calculate mod, modular addition, subtraction, multiplication, exponentiation, and modular inverse for any integers.
How it works
- Enter values A, B, and modulus N in the input fields.
- Select the operation: Mod, Add, Subtract, Multiply, Exponentiation, or Inverse.
- The result updates instantly without any page reload.
- For modular inverse, the tool uses the extended Euclidean algorithm and shows a warning when no inverse exists.
- For modular exponentiation, fast exponentiation (square-and-multiply) handles very large exponents accurately.
- Copy the result with the copy button for use in other calculations.
Use cases
- Verify cryptographic computations like RSA key generation steps.
- Check solutions to number theory homework problems.
- Compute cyclic group operations in abstract algebra.
- Test primality-related divisibility conditions.
- Calculate clock arithmetic (e.g., hours after N hours).
- Explore Diffie-Hellman key exchange intermediate values.
Frequently Asked Questions
Last updated: 2026-06-13 ·
Reviewed by Nham Vu