Modular Inverse Calculator
Find the modular inverse used in RSA and modular arithmetic.
Result
How it is calculated
The modular inverse of a modulo m is the number x such that a × x ≡ 1 (mod m). It exists only when gcd(a, m) = 1, that is, when a and m share no common factor. The tool reduces a into the range 0 to m − 1 (a negative a is wrapped around), then runs the extended Euclidean algorithm, which finds the gcd and the coefficients of a·x + m·y = gcd. If the gcd is 1, x taken modulo m is the inverse. Otherwise it reports that no inverse exists and shows the gcd. The modulus must be 2 or more, and a and m are treated as whole numbers.
Worked example
Find 7⁻¹ mod 26. Euclid: 26 = 3×7 + 5, 7 = 1×5 + 2, 5 = 2×2 + 1, so the gcd is 1. Back-substituting: 1 = 3×26 − 11×7. So x = −11, and −11 + 26 = 15. Check: 7 × 15 = 105 = 4×26 + 1, which leaves remainder 1.
Common mistakes
- Looking for an inverse when a and m share a factor, such as 6 mod 26 (gcd 2). None exists, and the tool says so.
- Confusing the modular inverse with the ordinary reciprocal 1 ÷ a. Here the answer is a whole number.
- Giving a modulus of 1 or less, which has no meaningful inverse.
- Forgetting to reduce a negative result. Inverses are quoted between 0 and m − 1, so −11 becomes 15.
- Typing a decimal value for a or m. Only whole numbers make sense here.
About this calculator
This calculator finds the modular multiplicative inverse of a number a modulo m — the value x such that a·x ≡ 1 (mod m) — using the extended Euclidean algorithm. An inverse exists only when gcd(a, m) = 1, i.e. a and m are coprime.
Cryptography engineers and computer science students use modular inverses constantly in RSA key generation (finding the private exponent d from the public exponent e), Diffie–Hellman variants, and other modular-arithmetic algorithms; they're also a standard topic in number theory courses.
Was this helpful?
You can pick up to 3 reactions.
Popular calculators
Loan Calculator
Monthly payment, total interest and full amortization schedule.
Percentage Calculator
Percent change, percent of, and ratio calculations.
Discount Calculator
Calculate final price, savings, and discount amount.
BMI Calculator
Body mass index from height and weight (metric or imperial).
Age Calculator
Compute your exact age in years, months and days from a birth date.
Compound Interest Calculator
Calculate the final amount and interest earned with compounding.
All Calculators
- Loan Calculator
- Profit Calculator
- Discount Calculator
- BMI Calculator
- Percentage Calculator
- Ideal Weight Calculator
- Age Calculator
- Pregnancy Due Date Calculator
- Compound Interest Calculator
- BMR Calculator (Basal Metabolic Rate)
- Tip Calculator
- Fuel Cost Calculator
- Date Difference Calculator
- Sleep Cycle Calculator
- Daily Water Intake Calculator
- Simple Interest Calculator
- Heart Rate Zones Calculator
- Running Pace Calculator
- Pet Age Calculator
- Calories Burned Calculator
- Macro Calculator
- TDEE Calculator (Total Daily Energy Expenditure)
- Waist-to-Hip Ratio Calculator
- Honor Roll Calculator
- One Rep Max (1RM) Calculator
- Ovulation Calculator
- Electricity Cost Calculator
- Unit Price Calculator
- Savings Goal Calculator
- Break-Even Point Calculator
- Paint Calculator
- Course Grade Average Calculator
- Business Days Calculator
- Time Duration Calculator
- Fuel Economy Calculator
- Temperature Converter
- Tile Calculator
- Aspect Ratio Calculator
- Roman Numeral Converter
- Goal Weight Timeline Calculator
- Salary Converter (Hourly to Annual)
- Credit Card Validator (Luhn)
- Body Surface Area (BSA) Calculator
- Feels-Like Temperature Calculator
- Ohm’s Law Calculator
- PPI (Pixel Density) Calculator
- Molar Mass Calculator
- Zodiac Sign Calculator (Western + Chinese)
- IBAN Validator
- Shoe Size Converter
- Country Info & Dialing Code Lookup
- Time Zone Difference (World Clock)
- CAGR (Compound Annual Growth Rate) Calculator
- Rule of 72 Calculator
- Blood Alcohol Content (BAC) Calculator
- Lean Body Mass (LBM) Calculator
- Pythagorean Theorem Calculator
- Speed Converter
- Download Time Calculator
- Date Calculator (Add/Subtract)
No calculators found
Comments (1)
A classic use is the private exponent in a textbook RSA example: with e equal to 7 and a totient of 40, the inverse is 23, and 7 times 23 is 161, one more than 4 times 40. The tool works with ordinary integers, so it suits teaching-sized numbers; real keys run to hundreds of digits and need big-integer software. Are you checking homework, or following a cryptography walk-through?