ForHosting KIT · Math

Bézout coefficients calculator

For 240 and 46 the greatest common divisor is 2, and 240 × (−9) + 46 × 47 gives 2, so x is −9 and y is 47. Enter two integers, not both zero, to get the gcd and one valid pair of coefficients. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
A
240
B
46
You get
Gcd
2
X
-9
Y
47
Check
2

Bézout's identity states that for any integers a and b that are not both zero, there exist integers x and y such that a times x plus b times y equals the greatest common divisor of a and b. Those coefficients are the constructive heart of linear Diophantine equations, modular inverses when the gcd is one, and classroom proofs that two numbers are coprime.

What Bézout's identity asserts and why coefficients matter

Every pair of integers that is not both zero has a well-defined non-negative greatest common divisor g. Bézout's identity goes further: it guarantees integers x and y for which a times x plus b times y equals that g. The existence proof is constructive and follows from the Euclidean remainder process.

Ordinary division repeatedly replaces a pair with the next remainder until zero appears; the last non-zero remainder is the gcd. Tracking how each remainder is written as an integer linear combination of the original inputs yields the coefficients at termination. Classroom texts often back-substitute quotients from the division table; production code usually updates two coefficient pairs in a single loop so no stack of remainders is stored.

Both approaches compute the same mathematical object. The coefficients are not unique: if one pair works, so does every pair shifted by integer multiples of b over g and a over g with opposite signs. This tool returns one particular solution from the iterative algorithm, always with a non-negative gcd, so scripts and graders can compare against a fixed convention without re-deriving the general solution set.

How to call the calculator and read the response

Send integers a and b. The pair zero and zero is also rejected, because gcd of zero and zero is undefined and no coefficients can make a meaningful Bézout equation. On success the response includes the normalized a and b, the gcd, x, y, a nested bezout object with the same coefficients, a numeric check equal to a times x plus b times y, an equation string such as two hundred forty times negative nine plus forty-six times forty-seven equals two, and an identity field stating the general relation.

Typical checks: for two hundred forty and forty-six the gcd is two with one valid solution x equals negative nine and y equals forty-seven; for a prime pair with gcd one the coefficients give a modular inverse of a modulo b after reducing x. Edge cases with a zero and a non-zero partner yield gcd equal to the absolute value of the non-zero input and a trivial coefficient pattern.

Where Bézout coefficients appear in practice

Contest programmers solve a times x plus b times y equals c by first computing the gcd and a base Bézout pair, then scaling and parametrizing the general solution when the gcd divides c. Cryptography students recover modular inverses for RSA toy examples and affine ciphers whenever the gcd of a and m equals one by reading the coefficient of a after reduction modulo m. Teachers assign constructive proofs that two integers are coprime and need a deterministic oracle that shows the linear combination, not only a true-or-false coprimality bit.

Data and systems engineers occasionally need explicit linear combinations when reconciling periodic schedules or stride arithmetic. Use the browser tool to check homework quickly, then automate the identical contract when your service needs bulk Diophantine checks. If you only need the plain gcd without coefficients, this landing still answers that need while teaching the stronger constructive Bézout result that underpins number-theory curricula and interview questions about extended Euclidean reasoning.

Linear Diophantine equations

Obtain a particular solution (x, y) for a*x + b*y = gcd, then scale and parametrize when solving a*x + b*y = c in contests or homework.

Modular inverse building block

When gcd(a, m) = 1, reduce the Bézout coefficient of a modulo m to recover a modular inverse for crypto and number-theory exercises.

What is Bézout's identity?

It states that for integers a and b not both zero, there exist integers x and y (Bézout coefficients) such that a*x + b*y equals gcd(a, b). This calculator returns one such pair together with the gcd.

Are the coefficients unique?

No. If (x, y) works, so does (x + k*(b/g), y - k*(a/g)) for any integer k. This tool returns one particular solution from the iterative algorithm.

What integer range is supported?

Each of a and b must be an integer with absolute value at most 9007199254740991 (Number.MAX_SAFE_INTEGER).

What does it cost?

The browser tool is free and runs locally.

How do Bézout coefficients give a modular inverse?

When the gcd of a and b is 1, the equation reads a·x + b·y equal to 1. Reducing x modulo b then gives the inverse of a modulo b, the number that multiplied by a leaves remainder 1.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/numth/bezout-identity

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/numth/bezout-identity \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"a":240,"b":46}'
{
  "a": 240,
  "b": 46
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "numth.bezout_identity",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

How to call the calculator and read the response

Aliases first or m for a, and second or n for b, are accepted for form-friendly clients. Non-integers, empty fields, and values outside the platform safe-integer absolute maximum are rejected with invalid_input and are not charged.

Where Bézout coefficients appear in practice

Because the capability is a pure parse engine, there is no model drift, no network dependency, and no stored state: the same pair always yields the same JSON for a fixed coefficient convention. API pricing is the published base of $0.002 per successful item; failed validation does not consume balance.

Teaching and automated checks

Show students the identity a*x + b*y = gcd with a stable JSON equation field, and wire the same contract into graders or CI fixtures.

Why are both a and b zero rejected?

gcd(0, 0) is undefined. There is no positive greatest common divisor, so Bézout's identity does not apply; the API returns invalid_input and does not charge.

Read the full KIT documentation →