Math calculator

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.

Modular Inverse inputs

Set up the calculation

Where this calculation appears

Inverses solve linear congruences and appear in cryptographic arithmetic, checksums, and cyclic indexing.

What the formula is measuring

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.

The roles assigned to integer a and positive modulus explain the operation that produces modular inverse.

Example from start to finish

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.

Manual method

Use the extended Euclidean algorithm to express 1 as ax+ny, then normalize x modulo n.

Where the shortcut stops

A non-coprime pair has no inverse. The modulus must exceed one, and the reported representative lies from zero through n−1.

Record the source conventions for Modular Inverse; Modular Inverse still requires the reader to validate the setup for modular inverse.

Interpreting changes in the inputs

Treat each labeled field as part of the definition, not merely an empty box. The field assignment determines what the displayed modular inverse describes. Convert measured values to compatible units first and retain their original precision until the final rounding choice.

How the result responds

Replacing a by any congruent integer leaves the inverse class unchanged. Predict that movement before recalculating the modular inverse; disagreement points to an input-role or sign issue.

An ordinary reciprocal multiplies to exactly one; a modular inverse multiplies to a number congruent to one. Here the requested quantity is specifically modular inverse.

Recording the answer

Report the modular inverse at a precision justified by the inputs. A long browser decimal is computational detail, not evidence that the source values were measured that accurately. When an exact symbolic form is conventional, keep it beside the rounded value so later work is not forced to reuse an early approximation.

Keep the supplied inputs with the result, including any units and the final rounding place. The displayed formula then preserves how the modular inverse was obtained.

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.

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.