Maths & numbers
Modular multiplicative inverse
Find an exact integer inverse and verify the modular product.
A clear answer. Here’s how.
Uses the extended Euclidean algorithm on a modulo positive m. An inverse exists only when gcd(a,m)=1. Returns the representative in [0,m) and verifies (a×inverse) mod m=1. Negative a is supported. Inputs are integer text of at most 80 digits, so large values do not pass through floating-point numbers.
See a worked example
Worked example
A fixed demonstration, separate from the values you enter above.
- Integer a
- 17
- Modulus m, greater than 1
- 3120
Example result
- Modular inverse
- 2753
- Verification (a × inverse) mod m
- 1