Bezout's Identity Calculator

Find the Bezout coefficients x and y such that ax + by = gcd(a, b) using the Extended Euclidean Algorithm.

Input Numbers

Find integers x, y such that: 56x + 15y = gcd(56, 15)

Bezout's Identity

1 = -4(56) + 15(15)

gcd(56, 15)

1

x

-4

y

15

Verification

56(-4) + 15(15) = 1

Algorithm Steps

Steprst
05610
11501
2111-3
34-14
433-11
51-415

Other Representations

1 = (-34)(56) + (127)(15)

1 = (-19)(56) + (71)(15)

1 = (11)(56) + (-41)(15)

1 = (26)(56) + (-97)(15)

Bezout's Identity

Theorem

For any integers a and b, there exist integers x and y such that ax + by = gcd(a, b).

Applications

  • Solving linear Diophantine equations
  • Finding modular multiplicative inverses
  • RSA cryptography

What Is Bézout's Identity?

Bézout's identity states that for any two non-zero integers a and b, there exist integers x and y such that ax + by = gcd(a,b). In other words, the greatest common divisor of a and b can be expressed as a linear combination of a and b. This calculator uses the extended Euclidean algorithm to find both the GCD and the Bézout coefficients x and y, showing the full step-by-step computation.

The identity is named after the 18th-century French mathematician Étienne Bézout, though the result was known earlier. It's a cornerstone of elementary number theory with practical applications in cryptography (computing modular inverses for RSA), solving linear Diophantine equations, and simplifying fractions. The calculator handles both positive and negative inputs, computing the GCD of the absolute values and adjusting the coefficients for the original signs.

Extended Euclidean Algorithm

The extended Euclidean algorithm maintains three sequences — remainders (r), s-coefficients, and t-coefficients — updating them with quotients at each step until the remainder reaches zero. The GCD is the last non-zero remainder, and its s and t values are the Bézout coefficients.

Extended Euclidean Algorithm Recurrence

r_i = r_{i−2} − q × r_{i−1} s_i = s_{i−2} − q × s_{i−1} t_i = t_{i−2} − q × t_{i−1} where q = floor(r_{i−2} / r_{i−1})

Where:

  • a, b= The two input integers — can be positive, negative, or zero
  • q= The integer quotient at each step — floor(r_{i−2} / r_{i−1})
  • s, t= The Bézout coefficients — satisfy s×a + t×b = gcd(a,b)

Understanding the Results

OutputDescription
GCD(a,b)The greatest common divisor — always positive. For (56, 15), gcd = 1.
Bézout IdentityThe linear combination: e.g., −4×56 + 15×15 = 1 for a=56, b=15.
Coefficients x, yThe x and y that satisfy ax + by = gcd(a,b)
Step-by-step tableEach iteration shows r, s, t, the quotient q, and the corresponding linear combination equation

How to Use This Calculator

  1. Enter a and b: Type two integers. Both can be positive, negative, or zero (but not both zero).
  2. View the GCD: The calculator computes the GCD and displays the Bézout identity.
  3. Explore the steps: The step-by-step table shows each iteration of the extended Euclidean algorithm with the values of r, s, t, q, and the linear combination equation at each stage.

Real-World Applications

Bézout's identity is the workhorse behind modular inverses. When gcd(a, n) = 1, the extended Euclidean algorithm finds x such that ax ≡ 1 (mod n) — that is, the modular inverse of a modulo n. This is how RSA private keys are generated: the decryption exponent d is the modular inverse of the public exponent e modulo φ(n). Without Bézout, public-key cryptography would be impossible.

In Diophantine equation solving, Bézout's identity tells you whether ax + by = c has integer solutions: solutions exist if and only if gcd(a,b) divides c. In Chinese Remainder Theorem computations, Bézout coefficients are used to combine modular congruences. In fraction simplification, dividing numerator and denominator by their GCD reduces a fraction to lowest terms.

Worked Examples

Bézout for 56 and 15

Problem:

Find gcd(56, 15) and express it as a linear combination 56x + 15y = gcd.

Solution Steps:

  1. 1Enter a = 56, b = 15.
  2. 2Extended Euclidean: 56 = 1×56 + 0×15; 15 = 0×56 + 1×15; 56 − 3×15 = 11 → r=11, s=1, t=−3; 15 − 1×11 = 4 → r=4, s=−1, t=4; 11 − 2×4 = 3 → r=3, s=3, t=−11; 4 − 1×3 = 1 → r=1, s=−4, t=15.
  3. 3GCD = 1. Bézout: (−4)×56 + 15×15 = −224 + 225 = 1.

Result:

gcd(56, 15) = 1, x = −4, y = 15. The modular inverse of 15 mod 56 is 15 (since 15×15 ≡ 1 mod 56).

Tips & Best Practices

  • The quotient q = floor(r_{i-2} / r_{i-1}) at each step — this is integer division rounding toward negative infinity.
  • Coefficients x and y are not unique — they form an infinite family: (x + k·b/gcd, y − k·a/gcd) for any integer k.
  • If gcd(a,b) = 1, the numbers are coprime and each has a modular inverse modulo the other.
  • The step-by-step table traces every iteration — use it to learn the algorithm or verify manual computations.

Frequently Asked Questions

Yes. The calculator computes the GCD of the absolute values, then adjusts the Bézout coefficients for the original signs. For negative inputs, the identity still holds: gcd(−a, b) = gcd(a, b), and the coefficients simply absorb the sign changes.
The calculator reports an error: 'Both numbers cannot be zero.' The GCD of 0 and 0 is undefined (or defined as 0 by convention, but no unique Bézout coefficients exist). At least one number must be non-zero.
Absolutely. If gcd(a, n) = 1, then the x coefficient from the extended Euclidean algorithm is a modular inverse of a modulo n: a×x ≡ 1 mod n. This is the standard method for computing inverses in cryptography. The calculator shows the Bézout coefficients directly.

Sources & References

Last updated: 2026-06-06

💡

Help us improve!

How would you rate the Bezout's Identity Calculator?

<>

Editorial Note

MyCalcBuddy Editorial Team

This page is maintained as an educational calculator reference.

Source

Formula Source: Handbook of Mathematical Functions

by Abramowitz & Stegun

UpdatedLast reviewed: May 2026
CheckedFormula checks are based on standard references and internal QA review.