How to use
- Enter two to six whole numbers, one per box. Leave the extra boxes empty.
- Read the GCF and LCM at once.
- Below the result, see each number’s prime factorization and every step of Euclid’s algorithm.
The GCF is also called the GCD (greatest common divisor) or HCF (highest common factor).
How the GCF and LCM are calculated
Prime factor method: write each number as a product of primes.
- GCF: multiply the primes that appear in every number, each at its lowest power.
- LCM: multiply every prime that appears anywhere, each at its highest power.
Euclid’s algorithm: divide the larger number by the smaller and keep the remainder. Repeat with the divisor and the remainder until the remainder is 0. The last divisor is the GCF.
For two numbers, LCM = a × b ÷ GCF. For three or more, work in pairs.
Examples
- 12 and 18: 12 = 2² × 3 and 18 = 2 × 3². The GCF is 2 × 3 = 6, and the LCM is 2² × 3² = 36.
- Euclid for 48 and 18: 48 = 2 × 18 + 12, then 18 = 1 × 12 + 6, then 12 = 2 × 6 + 0. The GCF is 6.
- 8, 12 and 20: gcd(8, 12) = 4, then gcd(4, 20) = 4. lcm(8, 12) = 24, then lcm(24, 20) = 120.
| Numbers | GCF | LCM |
|---|---|---|
| 12, 18 | 6 | 36 |
| 15, 20 | 5 | 60 |
| 15, 18 | 3 | 90 |
| 54, 36 | 18 | 108 |
| 8, 9, 21 | 1 | 504 |
| 8, 12, 20 | 4 | 120 |
Zero, negative numbers and coprime numbers
When the GCF is 1, the numbers are called relatively prime, or coprime, like 8, 9 and 21.
Every whole number divides 0, so gcd(a, 0) = a. By convention the LCM is 0 when any number is 0. Negative numbers use their absolute values, so the GCF and LCM are always positive.
To add fractions, the LCM of the denominators is the least common denominator. The fraction calculator uses it in its steps.