Modular Inverse Calculator
Find x such that ax leaves remainder one modulo a positive modulus. Its modular inverse sits beside the working formula for a quick arithmetic check.
Set up the calculation
The role of Modular Inverse in a larger problem
Inverses solve linear congruences and appear in cryptographic arithmetic, checksums, and cyclic indexing.
How the Modular Inverse rule is built
The roles assigned to integer a and positive modulus explain the operation that produces modular inverse.
An independent Modular Inverse calculation
Use the extended Euclidean algorithm to express 1 as ax+ny, then normalize x modulo n.
A modular inverse exists exactly when a and the modulus are coprime. It plays the role of division inside modular arithmetic. Modular Inverse also connects with derive the coefficients.
Assumptions to check in Modular Inverse
A non-coprime pair has no inverse. The modulus must exceed one, and the reported representative lies from zero through n−1.
Because 17×38=646 and 646 mod 43=1, the inverse of 17 modulo 43 is 38. This Modular Inverse example can be compared with solve a linear congruence.
Representatives of the same inverse
If x is an inverse modulo n, then x+kn is also an inverse for every integer k because adding an n-multiple does not change the residue. This page chooses the standard representative from zero through n−1 so different derivations can be compared consistently.
A second verification of Modular Inverse
Substitute the Modular Inverse solution into Integer a. This Modular Inverse check rejects false Modular Inverse branches and forbidden denominators.
Choose an easy Integer a value before running Modular Inverse. Predict Positive modulus, then compare it with the Modular Inverse output.
Before accepting Modular inverse, restore the Modular Inverse inputs Integer a and Positive modulus. Estimate Modular inverse independently. Then vary Positive modulus alone and observe the new Modular Inverse output. This isolates the changed part of Modular Inverse.
Validating Modular Inverse
Vary Integer a alone to test Modular Inverse sensitivity. Freeze Positive modulus and watch Modular inverse. Several simultaneous edits would hide which part of the Modular Inverse setup caused the change in Modular inverse.
Reviewing Modular Inverse in context
Record the first Modular Inverse setup before editing Integer a. A later value of Modular inverse should remain attached to its own inputs.
Questions about Modular Inverse
When does an inverse exist?
When gcd(a,n)=1.
Can the inverse be zero?
Not for a modulus greater than one.
How do I check it?
Multiply by a and take the remainder modulo n.