Skip to content

GCD and LCM Calculator

Enter two or more whole numbers and get their greatest common divisor (also called GCF or HCF) and their least common multiple. For two numbers you also see the steps of the Euclidean algorithm and the two numbers as a fraction in lowest terms, and each number is broken into prime factors.

Greatest common divisor

12

Least common multiple

720

As a fraction: 48/180 = 4/15

  • 48 = 2⁴ × 3
  • 180 = 2² × 3² × 5

Euclidean algorithm

  1. 180 = 3 × 48 + 36
  2. 48 = 1 × 36 + 12
  3. 36 = 3 × 12 + 0

How it works

  1. Type two to twenty whole numbers, separated by commas, spaces or new lines.
  2. Read the greatest common divisor and the least common multiple.
  3. Check the prime factorisation of each number, and the Euclidean steps when there are two numbers.
  4. Copy the summary.

What people use it for

  • Simplifying a fraction

    Divide the top and bottom by their greatest common divisor to reduce 48/180 to 4/15.

  • Repeating schedules

    Two buses leave every 12 and 18 minutes: they leave together again after the least common multiple, 36 minutes.

  • Cutting equal pieces

    Find the largest square tile that fits a 48 by 180 floor exactly.

Questions

What is the difference between GCD and LCM?
The greatest common divisor is the largest number that divides all the numbers exactly. The least common multiple is the smallest positive number that every one of them divides. For 12 and 18 they are 6 and 36.
How are they computed?
The GCD uses the Euclidean algorithm: replace the pair (a, b) by (b, a mod b) until the remainder is 0. The LCM of two numbers is a × b ÷ GCD, applied number after number for longer lists.
How big can the numbers be?
Up to 30 digits each and 20 numbers, with exact whole-number arithmetic. Prime factors are shown for numbers up to 1 000 000 000 000; above that the GCD and LCM are still exact but the factors are not listed.
What about 0 or negative numbers?
Only positive whole numbers are accepted. Zero is refused: mathematically the GCD of 0 and a number is that number, but 0 has no meaningful LCM, so leave zeros out.