Calculate the modular multiplicative inverse of a number modulo n using the extended Euclidean algorithm. Free tool for cryptography, number theory, and discrete mathematics.
Calculate the modular multiplicative inverse using the extended Euclidean algorithm
Definition: The modular inverse of a modulo n is a number x such that:
(a × x) ≡ 1 (mod n)
Existence: An inverse exists if and only if gcd(a, n) = 1
Algorithm: Extended Euclidean Algorithm finds both gcd and coefficients
Copy the code below to embed this calculator on your website
The modular multiplicative inverse is a fundamental concept in number theory and cryptography, essential for solving linear congruences and implementing cryptographic algorithms. Our Inverse Modulo Calculator uses the extended Euclidean algorithm to find the inverse efficiently and provides step-by-step solutions.
Whether you're working on RSA encryption, solving linear congruences, or studying abstract algebra, understanding modular inverses is crucial. The calculator demonstrates the extended Euclidean algorithm, showing how to find both the greatest common divisor and the coefficients needed for the inverse calculation.
Our calculator implements the extended Euclidean algorithm to find modular inverses:
The calculator will show an error if no inverse exists (when gcd(a, n) ≠ 1).
(a × x) ≡ 1 (mod n)
The modular inverse of a modulo n is a number x such that the product equals 1 modulo n
The extended Euclidean algorithm not only finds gcd(a, n) but also finds integers x and y such that:
ax + ny = gcd(a, n)
When gcd(a, n) = 1, the coefficient x is the modular inverse of a modulo n.
Modular inverses are used in numerous fields:
A modular inverse exists if and only if gcd(a, n) = 1. This means a and n must be coprime (relatively prime). If gcd(a, n) ≠ 1, then no inverse exists modulo n.
The extended Euclidean algorithm finds not only gcd(a, n) but also integers x and y such that ax + ny = gcd(a, n). When gcd(a, n) = 1, the coefficient x is the modular inverse of a modulo n.
The extended Euclidean algorithm runs in O(log min(a, n)) time, making it very efficient even for large numbers. This is much faster than brute force methods that would take O(n) time.
To verify that x is the inverse of a modulo n, check that (a × x) mod n = 1. For example, if 5 is the inverse of 3 modulo 7, then 3 × 5 = 15, and 15 mod 7 = 1.
Modular inverses are essential in RSA cryptography, solving linear congruences, implementing hash functions, error correction codes, and various algorithms in computer science and mathematics.
The modular multiplicative inverse is a powerful tool in number theory and cryptography, enabling efficient solutions to complex mathematical problems. Our Inverse Modulo Calculator demonstrates the extended Euclidean algorithm and provides step-by-step solutions for educational and practical purposes.
Ready to explore more mathematical concepts? Check out our Slope Calculator for linear function analysis, or use our Area Calculator for geometric calculations.
Find the slope of a line using two points or from a linear equation in various forms.
AlgebraCalculate parabola properties including vertex, focus, directrix, and axis of symmetry.
AlgebraSolve the classic diamond problem to find two numbers from their sum and product.
AlgebraSolve proportions and ratios instantly using cross multiplication method.
AlgebraConvert linear equations from standard form to slope-intercept form instantly.
AlgebraGet instant results with our optimized calculation engine
Precise calculations you can trust for any project
Works perfectly on all devices and screen sizes