Skip to content
Test versionSearch

Mathematics

Exact GCD, LCM, Bézout and modular inverse

Use signed exact integers for two- or three-number GCD/LCM, show Bézout coefficients or find a modular inverse when it exists.

How it worksFAQRelated tools

Content reviewed:

The example values can be changed. Press Calculate to update the result; you can download it as TXT or CSV and collect scenarios in this tab. JSON, HTML and TXT downloads keep your inputs and all result rows; long integers keep every digit you entered. Automatic recalculation after editing is off unless you switch it on. Nothing is saved, imported or sent automatically.

Signed inputs up to 100 digits, no decimals/scientific notation. Extended Euclidean algorithm gives nonnegative GCD/LCM; gcd(0,0)=0 and any zero gives lcm 0. Two-number coefficients verify a*x+b*y=gcd. Third input only for three-number mode. Inverse needs positive modulus b at least 2 and gcd 1; absence reported explicitly. No prime-factor view here or cryptographic claim.

Decimal results are approximate. Inputs stay in this browser tab.

How it works

Own exact integer algorithms: sieve/trial division, Fibonacci recurrence, elementary counting and extended Euclid. Signed inputs up to 100 digits, no decimals/scientific notation. Extended Euclidean algorithm gives nonnegative GCD/LCM; gcd(0,0)=0 and any zero gives lcm 0. Two-number coefficients verify a*x+b*y=gcd. Third input only for three-number mode. Inverse needs positive modulus b at least 2 and gcd 1; absence reported explicitly. No prime-factor view here or cryptographic claim.

Worked example

With these example values the calculator gives the result below. You can change any value in the form above.

Inputs

Operation
Two integers with Bézout identity
Signed integer a
48
Signed integer b or positive modulus
18

Result

Nonnegative GCD
6
Nonnegative LCM
144
Bézout coefficient x
-1
Bézout coefficient y
3
Exact a*x+b*y
6

Frequently asked questions

How do I find the GCD and LCM of two or three numbers?

Choose two-number or three-number mode and enter signed integers. The extended Euclidean algorithm gives a nonnegative GCD and LCM. The editable example uses 48 and 18 and a third number 30.

What size of numbers can I enter?

Signed integers up to 100 digits, with no decimals or scientific notation.

What are the special cases for zero?

gcd(0,0) is 0, and any zero input gives an lcm of 0.

What are Bezout coefficients?

For two numbers, the tool shows coefficients x and y and verifies a*x + b*y = gcd.

When does a modular inverse exist?

The inverse needs a positive modulus b of at least 2 and a gcd of 1. If no inverse exists, its absence is reported explicitly.

Does the tool give prime factors or cryptographic assurance?

No. There is no prime-factor view here and no cryptographic claim.