Extended Euclidean Calculator

ax + by = gcd(a,b)

CalculatorsFreeNo Signup
4.5(482 reviews)
All Tools

Loading tool...

About Extended Euclidean Calculator

An extended Euclidean algorithm calculator computing gcd(a,b) and Bézout coefficients x,y satisfying ax+by=gcd(a,b). Shows each step of the algorithm with quotients and remainders. Essential for modular inverses. Client-side.

Extended Euclidean Calculator Features

  • GCD computation
  • Bézout coefficients
  • Step-by-step
  • Modular inverse
  • Quotient table
Extended Euclidean: find gcd(a,b) AND x,y with ax+by=gcd(a,b). Example: gcd(35,15)=5, with 35·1+15·(−2)=5. Bézout's identity guarantees such x,y always exist. The algorithm works by back-substitution through the GCD computation steps.

How to Use

Enter a and b:

  • GCD: Greatest common divisor
  • x,y: Bézout coefficients
  • Steps: Full algorithm trace

The Algorithm

Run Euclidean: a=q₁b+r₁, b=q₂r₁+r₂, ... until remainder=0. Then back-substitute: express each remainder in terms of a,b. The last nonzero remainder is gcd(a,b) = ax+by.

Key Uses

  • Modular inverse: a⁻¹ mod m (when gcd(a,m)=1)
  • Solving linear Diophantine equations
  • CRT construction
  • RSA key generation

Step-by-Step Instructions

  1. 1Enter a and b.
  2. 2Run algorithm.
  3. 3Get gcd.
  4. 4Find x,y.
  5. 5Verify ax+by=gcd.

Extended Euclidean Calculator — Frequently Asked Questions

How does this give modular inverses?+

If gcd(a,m)=1, then ax+my=1, so ax≡1(mod m), meaning x is a⁻¹ mod m. The Extended Euclidean directly computes this. It's the most common method for finding modular inverses.

Are the coefficients unique?+

No! If ax₀+by₀=gcd, then a(x₀+kb/gcd)+b(y₀−ka/gcd)=gcd for any integer k. The algorithm gives the 'minimal' solution. Other solutions form an arithmetic progression.

What's the time complexity?+

O(log(min(a,b))) steps — same as regular Euclidean. Each step reduces the numbers by at least half (Fibonacci-like worst case). Extremely efficient, even for numbers with hundreds of digits.

Share this tool: