StatGardenREF. DESK
Calculators/Maths/Modular multiplicative inverse
Maths

Modular multiplicative inverse calculator

Finds x such that a·x ≡ 1 (mod n), using the extended Euclidean algorithm.

What this calculator does

Modular multiplicative inverse works out finds x such that a·x ≡ 1 (mod n), using the extended Euclidean algorithm. Enter your own figures above and the answer updates as you type: nothing is fixed in the code, so the result reflects exactly the numbers you supply.

The formula this calculator evaluates is printed under the tool and explained below, so you can check the working by hand or reuse it in a spreadsheet.

The formula

FormulaExists iff gcd(a,n)=1; found from a·x+n·y=1 via the extended Euclidean algorithm, then x mod n

The inputs explained

FieldWhat to enter
aA number. Starts at 7.
n (modulus)A number. Starts at 26.

Worked examples

Every figure in the tables below is produced by this page’s own calculator at build time, so the numbers and the tool always agree. Select any row to load that scenario.

How the answer changes with a

Every other input is held at the calculator’s starting values while a varies. Select any row to load that scenario into the calculator.

How the answer changes with a
aNo inverse existsa mod n
3.5gcd(a,n) = 2, not 14N/A
5.25211 (should equal 1)5
7151 (should equal 1)7
10.5191 (should equal 1)11
14gcd(a,n) = 2, not 114N/A
2151 (should equal 1)21