1001Ferramentas
🔗Calculators

GCD with Bezout Coefficients

Compute gcd(a,b) and Bezout coefficients x,y where a·x + b·y = gcd.

Bézout's identity and the extended Euclidean algorithm

Bézout's identity states that for any integers a, b there exist integers x, y such that a · x + b · y = gcd(a, b). The extended Euclidean algorithm computes the GCD together with these coefficients: it runs the standard Euclidean recursion gcd(a, b) = gcd(b, a mod b) and back-substitutes the remainders to recover x and y. Example: gcd(15, 12) = 3 with 15 · 1 + 12 · (−1) = 3. The coefficients are not unique — adding k · (b/gcd) to x and subtracting k · (a/gcd) from y gives another valid pair. The algorithm still runs in O(log min(a, b)).

Cryptographic and algorithmic uses

  • Modular inverse — essential for RSA: d ≡ e^(−1) (mod φ(n)) is exactly the Bézout coefficient of e.
  • Linear Diophantine equations ax + by = c are solvable iff gcd(a, b) | c; the extended algorithm produces one solution.
  • Chinese Remainder Theorem — the constructive proof uses Bézout coefficients to combine congruences with coprime moduli.
  • Network and graph algorithms — shortest-path problems with negative weights (Bellman–Ford) and cycle-detection routines use related GCD-based reasoning.

FAQ

Are the Bézout coefficients unique? No. Given one pair (x, y), every (x + k · b/g, y − k · a/g) with integer k and g = gcd(a, b) is also valid.

Can the coefficients be negative? Yes — at least one of x and y is typically negative when both a, b > 0.

When does the modular inverse a^(−1) mod n exist? Only when gcd(a, n) = 1. The extended algorithm then returns coefficients with a · x + n · y = 1, so x mod n is the inverse.

Is there a binary version? Yes — the binary extended GCD avoids division and uses only shifts and subtractions, useful in hardware and constant-time cryptographic implementations.

Related Tools

📐

Linear Regression Slope and Intercept (Least Squares)

Paste two comma-separated lists of paired X and Y values and get the ordinary least squares coefficients a and b of the line y = ax + b.

GCD Calculator

Calculate the Greatest Common Divisor (GCD) of two or more numbers using the Euclidean algorithm. Instant result.

📐

Timber Design Strength (kmod, NBR 7190)

Computes the timber design strength per the Brazilian NBR 7190, f_d = k_mod1 · k_mod2 · k_mod3 · f_k / γ_w, where the three modification factors correct the characteristic strength for load duration, service moisture class and timber grade, and γ_w is the material partial safety factor. Timber is the only common structural material whose strength falls with the DURATION of the applied load, and that is what k_mod1 encodes: it is 1.10 for instantaneous action and only 0.60 for permanent load, so the same member is worth nearly twice as much under impact as under self weight. In the most common design combination — long-duration action (0.70), moisture class 1 or 2 (1.00), first-grade sawn timber (1.00) and compression parallel to the grain with γ_wc = 1.4 — the factors cancel such that the design strength comes out exactly half the characteristic value, a shortcut worth memorising to sanity-check any result. Enter the three modification factors, the characteristic strength and the partial safety factor.

🔢

GCD of Multiple Numbers Calculator

Calculate the GCD (greatest common divisor) of a list of integers all at once. Enter the values separated by commas and see the result instantly.

📉

Linear Regression OLS Calculator

Computes simple linear regression coefficients by ordinary least squares method from a list of x y data pairs.

GCD Calculator (Euclidean Algorithm)

Returns the greatest common divisor of two integers through repeated remainder division, the Euclidean algorithm. Signs are ignored and decimals truncated.

The results provided by this tool are for general informational and educational purposes only and do not constitute professional, financial, medical, legal, tax or accounting advice. Always confirm important decisions with a qualified professional and official sources.