Math & Geometry
GCD & LCM Calculator
Greatest common divisor and least common multiple of a list of whole numbers.
Greatest common divisor and least common multiple
The greatest common divisor (GCD, also called highest common factor) of several whole numbers is the largest number that divides all of them exactly. The least common multiple (LCM) is the smallest positive number that all of them divide into. For 12, 18 and 30 the GCD is 6 and the LCM is 180. The calculator uses Euclid's algorithm, which repeatedly replaces the larger number by the remainder of dividing it by the smaller, and is fast even for very large numbers.
For two numbers the two are linked: GCD × LCM = the product of the numbers.
Practical uses
The GCD simplifies fractions and ratios (12/18 becomes 2/3) and splits things into the largest equal groups — cutting boards of 120 cm and 180 cm into equal pieces without waste gives pieces of 60 cm. The LCM finds common denominators for adding fractions and solves scheduling problems: buses every 12 and 18 minutes leave together every 36 minutes.
Formula & method
GCD by Euclid: gcd(a, b) = gcd(b, a mod b)LCM(a, b) = |a × b| ÷ GCD(a, b)Worked example
GCD and LCM of 12, 18 and 30
- Divisors shared by all three: 1, 2, 3, 6 → GCD = 6
- Prime factors: 12 = 2²·3, 18 = 2·3², 30 = 2·3·5
- LCM = 2² × 3² × 5
Answer: GCD = 6 and LCM = 180.
Frequently asked questions
What are GCD and LCM used for?
GCD simplifies fractions; LCM finds common denominators and repeating schedules.
What is Euclid's algorithm?
gcd(a, b) = gcd(b, a mod b), repeated until the remainder is zero; the last non-zero value is the GCD.
Is GCD the same as HCF?
Yes. Highest common factor and greatest common divisor mean the same thing.
What if the GCD is 1?
The numbers are coprime: they share no factor other than 1.
How many numbers can I enter?
As many as you like, separated by spaces or commas.
Can I use negative numbers?
Yes; signs are ignored, and the results are positive.
How is LCM used with fractions?
The LCM of the denominators is the lowest common denominator for adding or subtracting fractions.