Extended Euclidean Algorithm: GCD, Bézout & Congruences

Computes GCD and LCM, reconstructs the Bézout identity and solves linear Diophantine equations, modular inverses and linear congruences step by step

Inputs

ax+by=gcd(a,b)a\,x + b\,y = \gcd(a,b)

Integers of up to 40 digits, with optional sign.

Examples

GCD(a, b)

2

LCM(a, b)

5520

Coefficient x

−9

Coefficient y

47

Bézout identity

240·(−9) + 46·47 = 2

Derivation & verification

Successive divisions
240 = 5·46 + 10
46 = 4·10 + 6
10 = 1·6 + 4
6 = 1·4 + 2
4 = 2·2 + 0
Back-substitution
2 = 1·6 − 1·4
2 = (−1)·10 + 2·6
2 = 2·46 − 9·10
2 = (−9)·240 + 47·46

Verification

Identity a·x + b·y = gcd
−2160 + (2162) = 2
The GCD divides both integers
2 | 240 ∧ 2 | 46
gcd · lcm = |a·b|
2 · 5520 = 11040

Fundamentals & Explanation