webtrajans
en

GCD and LCM Calculator

Enter two to ten whole numbers to get their greatest common divisor and least common multiple, with every step of the Euclidean algorithm shown.

GCD · Greatest common divisor–
LCM · Least common multiple–

Prime factorization

With factors: GCD = lowest powers of shared primes, LCM = highest powers of all primes

Euclidean algorithm (step by step)

    LCM(a, b) = a × b ÷ GCD(a, b)

    This tool runs entirely in your browser; your data is never sent to a server.

    How to use

    1. 1Type 2 to 10 whole numbers separated by commas, spaces or semicolons.
    2. 2Read the GCD and LCM instantly; a “Coprime” label appears when the GCD is 1.
    3. 3Check the prime factorization of each number.
    4. 4Open the step-by-step section to follow the Euclidean algorithm.

    The Euclidean algorithm

    The GCD — also called the greatest common factor (GCF) or highest common factor (HCF) — is found with Euclid’s algorithm: divide the larger number by the smaller, replace the pair with the divisor and the remainder, and repeat until the remainder is 0. For 84 and 126: 126 = 1 × 84 + 42, then 84 = 2 × 42 + 0, so the GCD is 42. For more than two numbers the algorithm is applied pairwise: gcd(a, b, c) = gcd(gcd(a, b), c). Every division step is listed, so you can follow or copy the working for homework.

    LCM from the GCD and from prime factors

    The least common multiple follows from the identity lcm(a, b) = a × b ÷ gcd(a, b); for 84 and 126 that is 84 × 126 ÷ 42 = 252. The prime-factor method gives the same result: 84 = 2² × 3 × 7 and 126 = 2 × 3² × 7. The GCD takes the lowest power of each shared prime (2 × 3 × 7 = 42), and the LCM the highest power of every prime that appears (2² × 3² × 7 = 252). The LCM is what you need to find the lowest common denominator when adding fractions.

    Big numbers and edge cases

    Calculations use JavaScript BigInt, so the GCD and LCM stay exact even for numbers with dozens of digits. Prime factorization uses trial division with a time limit; if a number has very large prime factors, the remaining cofactor is shown and marked “partially factored”. Negative numbers are treated by their absolute value, gcd(a, 0) = a, and the LCM of any set containing 0 is 0.

    Frequently asked questions

    What is the difference between GCD and LCM?

    The GCD is the largest number that divides all the inputs evenly; the LCM is the smallest number that all the inputs divide into. The GCD simplifies fractions, the LCM gives a common denominator.

    Is GCD the same as GCF or HCF?

    Yes. Greatest common divisor, greatest common factor and highest common factor are three names for the same number.

    What does coprime mean?

    Two numbers are coprime (relatively prime) when their GCD is 1, like 8 and 15. Their LCM is then simply their product.

    How do I find the LCM of three numbers?

    Enter all three; the tool computes lcm(lcm(a, b), c) and shows each intermediate step.

    Not happy with the results?

    Talk to Webin Agency about fast, SEO-friendly websites, e-commerce and Google Ads management.

    Get free advice

    Related tools