GCD and LCM Calculator with Exact Steps
Calculate the exact GCD and LCM of two signed integers up to 200 digits, with Euclidean steps and clear zero rules.
Calculate the GCD and LCM of two integers
Enter signed whole numbers with up to 200 digits. Decimals and exponent notation are not accepted.
Try an example
What are the GCD and LCM?
For nonzero inputs, the greatest common divisor is the largest positive integer that divides both inputs evenly. It is also called the greatest common factor (GCF) or highest common factor (HCF). The least common multiple is the smallest positive integer divisible by both nonzero inputs.
How to use this calculator
- Enter two whole integers, optionally with a leading sign. Each may contain up to 200 digits.
- Choose Calculate to see both exact answers and the Euclidean remainder steps.
- Use Copy results to copy a plain-text GCD and LCM summary.
How the calculation works
The Euclidean algorithm repeatedly divides and replaces the pair with the divisor and remainder. When the remainder reaches zero, the last nonzero divisor is the GCD. The LCM is calculated as (|a| ÷ GCD) × |b| to keep the intermediate product smaller. BigInt arithmetic keeps integer results exact within the stated input limit. The arithmetic runs in your browser using BigInt; this page uses no calculation server.
For example, 12 and 18 have a GCD of 6 and an LCM of 36. The check 6 × 36 = 12 × 18 confirms the result. Negative signs do not change either answer. This calculator defines GCD(0, 0) as 0 and returns an LCM of 0 when either input is zero.
GCD and LCM calculator features
- Two signed whole-number inputs with a clear 200-digit limit
- Exact BigInt GCD and LCM results
- Euclidean division steps and an LCM identity check
- Examples, reset, and copyable results
Frequently asked questions
Can I enter decimals?
No. GCD and LCM are calculated from whole integers. Decimal and exponent notation are rejected.
What happens with negative values or zero?
Signs are ignored when finding both nonnegative answers. The GCD of 0 and 0 is defined as 0 here; the LCM is 0 if either value is 0.
Can I calculate the GCD and LCM of more than two values?
This page accepts two values. For a list of numbers, use the multi-number GCD and LCM calculator.