Bezout Coefficients Calculator
Enter integers a and b to get the GCD and Bezout coefficients x and y.
Result
How it is calculated
The tool runs the extended Euclidean algorithm on two integers a and b. It repeats a = q·b + r, replacing (a, b) by (b, r) until the remainder is 0, while updating a pair of coefficients at each step so that the current remainder is always a combination of the original a and b. The last non-zero remainder is the GCD, and the tracked coefficients are x and y with a·x + b·y = gcd(a, b). Both inputs must be whole numbers; a decimal such as 4.5 returns no result, and a = b = 0 is not allowed. Negative integers work, and the GCD is always reported as positive. The pair (x, y) is one valid solution; infinitely many others exist.
Worked example
Take a = 240 and b = 46. Divisions: 240 = 5·46 + 10, 46 = 4·10 + 6, 10 = 1·6 + 4, 6 = 1·4 + 2, 4 = 2·2 + 0. The last non-zero remainder is 2, so the GCD is 2. Substituting back through the steps gives x = -9 and y = 47. Check: 240 × (−9) + 46 × 47 = −2160 + 2162 = 2, which matches the GCD.
Common mistakes
- Entering decimals or fractions; the identity works for integers only, so 4.5 and 6 give nothing.
- Expecting a unique answer: other pairs such as (x + 46, y − 240) also satisfy the equation, and the tool returns just one.
- Using the result to find a modular inverse when the GCD is not 1; an inverse of a modulo b exists only if gcd(a, b) = 1.
- Forgetting that a negative x is normal; to get the inverse of a mod b, add b to a negative x.
- Reading y as the coefficient of a; x multiplies a and y multiplies b.
Sources
- Handbook of Applied Cryptography, Chapter 2: Mathematical Background (Algorithm 2.107, extended Euclidean algorithm) — Menezes, van Oorschot, Vanstone, CRC Press, 1996
About this calculator
Bezout's identity states that for any integers a and b, there exist integers x and y — the Bezout coefficients — satisfying ax + by = gcd(a, b). This calculator finds x, y and the GCD using the extended Euclidean algorithm, which runs the ordinary GCD algorithm forward while tracking the coefficients backward through each remainder step.
Beyond number theory, Bezout coefficients are the standard way to compute a modular multiplicative inverse — essential in RSA and other cryptographic key generation — and they underlie solving linear Diophantine equations of the form ax + by = c.
Was this helpful?
You can pick up to 3 reactions.
Popular calculators
Loan Calculator
Monthly payment, total interest and full amortization schedule.
Percentage Calculator
Percent change, percent of, and ratio calculations.
Discount Calculator
Calculate final price, savings, and discount amount.
BMI Calculator
Body mass index from height and weight (metric or imperial).
Age Calculator
Compute your exact age in years, months and days from a birth date.
Compound Interest Calculator
Calculate the final amount and interest earned with compounding.
All Calculators
- Loan Calculator
- Profit Calculator
- Discount Calculator
- BMI Calculator
- Percentage Calculator
- Ideal Weight Calculator
- Age Calculator
- Pregnancy Due Date Calculator
- Compound Interest Calculator
- BMR Calculator (Basal Metabolic Rate)
- Tip Calculator
- Fuel Cost Calculator
- Date Difference Calculator
- Sleep Cycle Calculator
- Daily Water Intake Calculator
- Simple Interest Calculator
- Heart Rate Zones Calculator
- Running Pace Calculator
- Pet Age Calculator
- Calories Burned Calculator
- Macro Calculator
- TDEE Calculator (Total Daily Energy Expenditure)
- Waist-to-Hip Ratio Calculator
- Honor Roll Calculator
- One Rep Max (1RM) Calculator
- Ovulation Calculator
- Electricity Cost Calculator
- Unit Price Calculator
- Savings Goal Calculator
- Break-Even Point Calculator
- Paint Calculator
- Course Grade Average Calculator
- Business Days Calculator
- Time Duration Calculator
- Fuel Economy Calculator
- Temperature Converter
- Tile Calculator
- Aspect Ratio Calculator
- Roman Numeral Converter
- Goal Weight Timeline Calculator
- Salary Converter (Hourly to Annual)
- Credit Card Validator (Luhn)
- Body Surface Area (BSA) Calculator
- Feels-Like Temperature Calculator
- Ohm’s Law Calculator
- PPI (Pixel Density) Calculator
- Molar Mass Calculator
- Zodiac Sign Calculator (Western + Chinese)
- IBAN Validator
- Shoe Size Converter
- Country Info & Dialing Code Lookup
- Time Zone Difference (World Clock)
- CAGR (Compound Annual Growth Rate) Calculator
- Rule of 72 Calculator
- Blood Alcohol Content (BAC) Calculator
- Lean Body Mass (LBM) Calculator
- Pythagorean Theorem Calculator
- Speed Converter
- Download Time Calculator
- Date Calculator (Add/Subtract)
No calculators found
Comments (1)
The coefficients also solve equations of the form ax + by = c, as long as c is a multiple of the GCD. For 240 and 46 the GCD is 2, so c = 10 works: scale x = -9 and y = 47 by 5 to get x = -45 and y = 235, and check that 240 times -45 plus 46 times 235 equals 10. If c is not a multiple, no integer solution exists. What kind of equation are you solving?