bezout calculator

Bezout Identity Calculator

Enter two integers a and b to find integers x and y such that:

a·x + b·y = gcd(a, b)

What Is a Bezout Calculator?

A Bezout calculator finds numbers that satisfy Bezout's identity:

a·x + b·y = gcd(a, b)

For any integers a and b (not both zero), there are always integers x and y that make this true. Those values are called Bezout coefficients.

How to Use This Calculator

  • Enter integer values for a and b.
  • Click Calculate.
  • The tool returns:
    • gcd(a, b)
    • One valid pair of coefficients (x, y)
    • A direct verification of the equation
    • Euclidean algorithm steps

You can use positive, negative, or very large integers. The calculator uses JavaScript BigInt to support large exact values.

Why Bezout's Identity Matters

1) Modular Arithmetic and Inverses

If gcd(a, n) = 1, then a has a modular inverse mod n. The coefficient x from Bezout's identity gives that inverse.

2) Solving Linear Diophantine Equations

For equations of the form a·x + b·y = c, a solution exists if and only if gcd(a, b) divides c.

3) Cryptography

Algorithms like RSA frequently use the extended Euclidean algorithm to compute modular inverses efficiently.

How the Math Works (Short Version)

The calculator uses the Extended Euclidean Algorithm. Standard Euclid finds only the gcd; the extended version also tracks the coefficients that produce that gcd.

At each step, we reduce the pair (a, b) using division with remainder until the remainder is zero. The last non-zero remainder is the gcd, and the tracked coefficients become Bezout coefficients.

Worked Example

For a = 240 and b = 46, the result is:

  • gcd(240, 46) = 2
  • One solution: x = -9, y = 47
  • Check: 240(-9) + 46(47) = -2160 + 2162 = 2

Using Bezout Coefficients to Solve a·x + b·y = c

Suppose your calculator gives a·x₀ + b·y₀ = d, where d = gcd(a,b). If d divides c, multiply both coefficients by c/d:

x = x₀·(c/d),   y = y₀·(c/d)

That gives one particular integer solution for a·x + b·y = c.

Common Mistakes

  • Entering decimals or fractions instead of integers.
  • Assuming coefficients are unique (they are not; many pairs work).
  • Forgetting that gcd(a,b) is always non-negative.
  • Trying to find a modular inverse when gcd is not 1.

Quick FAQ

Are x and y unique?

No. If (x, y) is one solution, there are infinitely many others.

Can a or b be negative?

Yes. The identity still holds with integer coefficients.

What if both numbers are zero?

Bezout coefficients are not meaningful there, and gcd(0,0) is undefined for this calculator.

Final Thoughts

A Bezout calculator is a compact but powerful number theory tool. Whether you're checking homework, building cryptography code, or solving integer equations, this identity gives a practical bridge between gcds and linear combinations.

🔗 Related Calculators