GCD & LCM Calculator
Compute the greatest common divisor (GCD) and least common multiple (LCM) of two or three positive integers with exact BigInt arithmetic and the Euclidean algorithm working shown.
Try an example
Enter two or more positive integers to see the GCD and LCM.
How to use
- 1
Enter the numbers
Type two or three positive integers. C is optional.
- 2
Read GCD and LCM
The greatest common divisor and least common multiple are shown.
- 3
Read the working
The Euclidean algorithm steps and the LCM = A × B ÷ GCD calculation are displayed.
Features
- GCD and LCM of two or three integers with exact BigInt arithmetic (up to 10¹²)
- Euclidean algorithm steps shown as substituted working
- The LCM = A × B ÷ GCD relation displayed alongside
- Coprime detection (GCD = 1) at a glance; inputs are never transmitted
Use cases
Check divisors homework
Verify hand-worked GCD and LCM problems against the Euclidean steps.
Fraction arithmetic
Find the LCM of denominators for common denominators, and the GCD for reducing.
Verify program output
Compare your gcd/lcm function results against exact big-integer values.
Details
The greatest common divisor (GCD) is the largest integer that divides two or more numbers, computed efficiently by the Euclidean algorithm. The least common multiple (LCM) is the smallest multiple they share, given by LCM = A × B ÷ GCD. The tool computes both exactly with BigInt (arbitrary-precision integers).
Three numbers are supported: the GCD composes pairwise (gcd(a, b, c) = gcd(gcd(a, b), c)), and the LCM composes pairwise as well. Inputs accept positive integers up to one trillion (10¹²), and results never overflow.
Conditions: all inputs must be positive integers (zero, negatives and decimals are not supported). Two coprime numbers (e.g. 7 and 13) give GCD = 1 and LCM = A × B. Inputs are never transmitted; all computation happens locally in your browser.
FAQ
What is the GCD?
The greatest common divisor is the largest integer that divides all the given numbers. For 12 and 18 the GCD is 6. The Euclidean algorithm finds it efficiently even for large numbers.
How do I find the LCM?
Use LCM = A × B ÷ GCD. For 12 and 18: 12 × 18 ÷ 6 = 36. For three or more numbers, compose pairwise: LCM(LCM(a, b), c).
What does coprime mean?
Two integers are coprime when their GCD is 1 — they share no common divisor other than 1. In that case the LCM is simply A × B.
Can I compute for three numbers?
Yes, up to three. The GCD composes pairwise as gcd(gcd(a, b), c), and the LCM likewise. Use the optional C field for the third number.
Related Tools
Prime Factorization
Factor any positive integer into primes. See the product form, exponent form (e.g. 2³×3²) and the number of divisors at once.
Fraction Calculator
Add, subtract, multiply and divide fractions with exact results. See the reduced answer plus mixed-number and decimal forms, with the working shown.
Permutation & Combination Calculator
Compute nCr, nPr and n! with exact big-integer arithmetic. Large results such as lottery odds never overflow, and every calculation shows its working step by step.
Quadratic Equation
Solve ax² + bx + c = 0 with real or complex roots, the discriminant and substitution into the quadratic formula.
All processing happens in your browser. Your files are never uploaded.
Verified: Known values (gcd(12,18)=6, lcm=36, three numbers → 12/360, coprime → 1), zero/negative/decimal/range errors, BigInt large numbers and the English page are covered by browser tests
Did you know?
The identity gcd(A, B) × lcm(A, B) = A × B always holds: for 12 and 18, 6 × 36 = 216 = 12 × 18. GCD and LCM are two faces of the same coin — knowing one instantly gives the other.