Extended Euclidean Algorithm (EEA)

The EEA computes the GCD of two integers and their Bézout coefficients, playing a fundamental role in number theory and cryptography.
7 Downloads
Updated 11 Apr 2025

View License

The extended Euclidean algorithm computes the GCD of two integer numbers while determining the Bézout coefficients 𝑥 and 𝑦 such that 𝑎𝑥+𝑏𝑦=gcd(𝑎,𝑏). This method is particularly useful in number theory and cryptography, especially for computing modular inverses, which are essential in methods such as RSA encryption.
The attached livescript provides the implementation of the extended Euclidean algorithm in both recursive and iterative versions. Each version is accompanied by an explanation of its correctness.

Cite As

Claudio Fontana (2025). Extended Euclidean Algorithm (EEA) (https://uk.mathworks.com/matlabcentral/fileexchange/180770-extended-euclidean-algorithm-eea), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2024b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.0