# Modular Inverse Calculator (Extended Euclidean Algorithm)

a⁻¹ mod m via extended Euclid with Bézout coefficients, an optional step table, and an a × a⁻¹ ≡ 1 (mod m) verification; RSA-sized inputs supported.

> Canonical page: https://elysiatools.com/en/tools/modular-inverse-calculator

- **Category:** Math & Numbers

- **Keywords:** modular inverse, extended euclidean, bezout identity, bezout coefficients, rsa, diophantine, modular arithmetic, number theory, multiplicative inverse

## Overview

The Modular Inverse Calculator computes the multiplicative inverse a⁻¹ mod m using the Extended Euclidean Algorithm, supporting standard integers as well as large RSA-scale values up to 10⁵¹². It automatically derives Bézout coefficients, confirms whether gcd(a, m) equals 1, validates the identity a × a⁻¹ ≡ 1 (mod m), and optionally displays the full step-by-step division and reduction table.

## Inputs

- **Value a** (text): The value to invert; negative values are reduced mod m first.
- **Modulus m** (text): Modulus, m ≥ 2. Inputs up to 10⁵¹² are accepted (RSA-sized).
- **Output style** (select)

## When to use

- Generating or verifying private key exponents in RSA key generation routines.
- Solving linear congruences, Diophantine equations, or finding decryption keys in classical affine ciphers.
- Debugging number theory assignments and modular arithmetic proofs that require step-by-step Bézout identity tracking.

## How it works

- Enter the value to invert (a) and the modulus (m, where m ≥ 2); negative values for a are automatically reduced modulo m.
- Select your preferred output style: a concise result with verification or a full Extended Euclidean step-by-step table.
- The algorithm calculates gcd(a, m) and computes Bézout coefficients s and t such that a·s + m·t = gcd(a, m).
- If gcd(a, m) = 1, the calculator outputs the normalized modular inverse along with the identity verification a × a⁻¹ ≡ 1 (mod m); otherwise, it reports that no inverse exists.

## Use cases

- Cryptographic key pair calculation where the private exponent d satisfies d ≡ e⁻¹ (mod φ(n)).
- Finding decryption multipliers for classical modular ciphers such as the affine cipher.
- Academic problem-solving in discrete mathematics and computational number theory.

## Frequently asked questions

### When does a modular inverse exist?

A modular inverse a⁻¹ mod m exists if and only if a and m are coprime, meaning gcd(a, m) = 1.

### How are negative values for a handled?

Negative values of a are automatically reduced modulo m to their positive canonical equivalent before computing the inverse.

### What is the maximum supported number size?

The calculator supports large integers up to RSA dimensions (10⁵¹²).

### What are Bézout coefficients in the output?

They are the integers s and t satisfying Bézout's identity, a·s + m·t = gcd(a, m), where s reduced modulo m yields the modular inverse.

### What does the verification step check?

It multiplies a by the computed inverse a⁻¹ and confirms that the product modulo m equals 1.

## Related tools

- [Boolean Algebra Simplifier (Karnaugh Map)](https://elysiatools.com/en/tools/boolean-algebra-simplifier): Minimal SOP via Quine–McCluskey with essential prime implicants, exact minimum cover, Gray-coded Karnaugh map, and full-assignment verification.
- [Dilution Ratio Converter (1:X ↔ 1/X ↔ %)](https://elysiatools.com/en/tools/dilution-ratio-converter): Convert dilution notations 1:X ↔ 1/X ↔ percent, with dilution factor, parts, and mixing volumes.
- [Extended Euclidean Algorithm (ax + by = gcd(a, b))](https://elysiatools.com/en/tools/extended-euclidean-algorithm): Bézout coefficients for any-sign integers with the full division-step table, lcm, and optional linear Diophantine solving (particular + general solution).
- [Modular Arithmetic Calculator (Add / Subtract / Multiply / Inverse / Power)](https://elysiatools.com/en/tools/modulo-arithmetic-converter): Exact BigInt modular arithmetic for values up to 10¹⁸: (a ± b) mod m, (a × b) mod m, a⁻¹ mod m via extended Euclid, and aᵇ mod m via fast exponentiation.
- [Truth Table Generator](https://elysiatools.com/en/tools/truth-table-generator): Complete truth table (≤ 6 variables, 64 rows) with alphabetical variable order, per-row function values, and canonical Σm/ΠM forms.
- [Angular Velocity Converter (rad/s / rpm / deg/s / Hz)](https://elysiatools.com/en/tools/angular-velocity-converter): Convert angular velocity (angular speed) between radian per second (rad/s, SI base), revolutions per minute (rpm = 2π/60 rad/s), degrees per second (deg/s = π/180 rad/s), and hertz (Hz, used as revolution per second = 2π rad/s). Converts via rad/s to the target unit and lists all four equivalents. Note: 1 Hz in angular-frequency context means one full revolution per second, so 1 Hz = 2π rad/s ≈ 6.283185307 rad/s. Reference: vinyl LP 33⅓ rpm ≈ 3.49 rad/s, car engine idle ~800 rpm ≈ 83.8 rad/s.
- [Duct Size Calculator (Flow Rate × Velocity)](https://elysiatools.com/en/tools/duct-size-calculator): Size a duct cross-section from the air flow rate Q and the design mean velocity v: area A = Q/v. Circular duct diameter D = √(4A/π). Rectangular duct with aspect ratio r = a/b gives b = √(A/r) and a = r·b, plus the ASHRAE equivalent diameter D_eq = 1.30·(a·b)^0.625/(a+b)^0.25. Flow rate in m³/s/m³/h/CFM, velocity in m/s; dimensions reported in mm and inches.
- [Fatigue Limit Calculator (Goodman / Gerber / Soderberg)](https://elysiatools.com/en/tools/fatigue-limit-calculator): Mean-stress fatigue correction under cyclic loading. Given stress amplitude σ_a, mean stress σ_m, and material σ_uts / σ_-1 (endurance limit) / σ_y, compute safety factors from three classical criteria: Modified Goodman (linear, conservative), Gerber (parabolic, better for ductile metals), and Soderberg (uses σ_y, most conservative). Reports the governing (smallest) value and whether the operating point lies inside the Goodman line.

## Samples

- [Web Image Processing Python Samples](https://elysiatools.com/en/samples/web-image-processing-python): Web Python image processing examples using PIL/Pillow including reading, saving, resizing, and format conversion
- [Android Image Processing Java Samples](https://elysiatools.com/en/samples/android-image-processing-java): Android Java image processing examples including reading/saving images, scaling, and format conversion
- [Android Image Processing Kotlin Samples](https://elysiatools.com/en/samples/android-image-processing-kotlin): Android Kotlin image processing examples including reading/saving images, scaling, and format conversion
- [Web Image Processing Rust Samples](https://elysiatools.com/en/samples/web-image-processing-rust): Web Rust image processing examples including image read/save, scaling, and format conversion
