GCD and LCM Calculator

Find the greatest common divisor (HCF) and least common multiple of two or more numbers, with Euclid’s steps shown.

Runs in your browser. Nothing is uploaded.

Two or more, separated by commas or spaces.

GCD (HCF)

–

Greatest common divisor

LCM

–

Least common multiple

Euclid’s algorithm

    Prime factors

    How to use the GCD and LCM Calculator

    1. Enter two or more whole numbers, separated by commas or spaces.
    2. Read the GCD (also called HCF) and the LCM.
    3. Follow Euclid's algorithm for the first two numbers.
    4. Compare the prime factors of each number in the table.

    Greatest common divisor and least common multiple

    Enter a list of whole numbers and the calculator finds the greatest common divisor (GCD, also called the highest common factor) and the least common multiple (LCM). It shows two methods side by side: Euclid’s algorithm and prime factorisation.

    Euclid’s algorithm

    More than 2,000 years old and still the fastest way to find a GCD by hand. For 252 and 105:

    • 252 = 2 × 105 + 42
    • 105 = 2 × 42 + 21
    • 42 = 2 × 21 + 0

    The last non-zero remainder, 21, is the GCD. The calculator lists these steps for the first two numbers, so you can check your own working.

    The prime factor method

    Write each number as a product of primes. The GCD takes each shared prime to its lowest power; the LCM takes every prime to its highest power. For 12 = 2² × 3 and 18 = 2 × 3², the GCD is 2 × 3 = 6 and the LCM is 2² × 3² = 36. The table shows the factors of every number you entered.

    Everyday uses

    • Simplifying fractions: divide the top and bottom by their GCD.
    • Adding fractions: the LCM of the denominators is the lowest common denominator.
    • Schedules: buses every 12, 15 and 20 minutes all leave together every LCM = 60 minutes.
    • Tiling and cutting: the GCD of two lengths is the largest equal piece that fits both exactly.

    Big numbers welcome

    Numbers with up to 30 digits are handled exactly, and up to 50 numbers at once.

    Private

    Calculations run in your browser.

    Frequently asked questions

    Is GCD the same as HCF and GCF?

    Yes. Greatest common divisor, highest common factor and greatest common factor all mean the largest number that divides every number in the list exactly.

    What is the LCM used for?

    The least common multiple is the smallest number every number divides into. It gives the lowest common denominator for adding fractions and answers "when do these events line up again?" questions.

    How does Euclid's algorithm work?

    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.

    What does coprime mean?

    Numbers are coprime when their GCD is 1: they share no factor other than 1, like 8 and 15.

    Can I use negative numbers or zero?

    Yes. Signs are ignored for the GCD, and the GCD of 0 and n is n. If any number is 0, the LCM is 0.

    Tutorials