Math · free · step by step

GCD and LCM Calculator

Find the greatest common divisor (GCD, HCF) and least common multiple (LCM) of two or more numbers, with prime factors and Euclid’s algorithm step by step.

Answer

Step by step

Worked examples

GCD and LCM examples

NumbersGCDLCM
12, 18636
8, 12424
24, 361272
15, 25575
14, 21742
16, 40880
45, 6015180
12, 18, 306180
24, 36, 6012360
1071, 4622123,562

More math

Other math tools

Questions

GCD and LCM Calculator FAQ

Free, private and works offline: everything is worked out in your browser.

How do you find the GCD (greatest common factor)?

Write each number as a product of primes and multiply the primes they share, each with its lowest power. 12 = 2² × 3 and 18 = 2 × 3², so GCD = 2 × 3 = 6. It is also called the HCF (highest common factor) or GCF.

How do you find the LCM (least common multiple)?

Take every prime that appears in any of the numbers, with its highest power: LCM(12, 18) = 2² × 3² = 36. For two numbers you can also use LCM = a × b ÷ GCD = 12 × 18 ÷ 6 = 36.

What is Euclid’s algorithm?

Divide the larger number by the smaller and keep the remainder; repeat with the smaller number and the remainder until the remainder is 0. The last non-zero remainder is the GCD: 1071 = 2 × 462 + 147, 462 = 3 × 147 + 21, 147 = 7 × 21 + 0, so GCD(1071, 462) = 21. It works quickly even for huge numbers.

What does co-prime mean?

Two numbers are co-prime (relatively prime) when their GCD is 1, so they share no prime factor, like 8 and 15. Their LCM is then just their product: 120.

When do I use GCD and LCM?

Use the GCD to simplify fractions (18/24 ÷ 6 = 3/4) and to split things into the largest equal groups. Use the LCM to find a common denominator and for “when will they line up again” problems, such as buses every 12 and 18 minutes meeting every 36 minutes.

Can it do more than two numbers?

Yes, up to 20 numbers at once, separated by commas or spaces, with the prime factor table and Euclid’s steps for each pair.

Built and maintained by Zubaer Ahammed · Updated · Runs on your device; nothing you add is uploaded