LCM and GCD Calculator
GCD (also called GCF or HCF) and LCM of 2 to 10 whole numbers, with the Euclidean steps and the prime factors of each number shown. How it works
Use the LCM and GCD Calculator
About the LCM and GCD Calculator
The GCD (greatest common divisor, also called the HCF or GCF) is the largest whole number that divides every number in a set. The LCM (least common multiple) is the smallest positive number that each of them divides. For 12 and 18 the GCD is 6 and the LCM is 36.
Methodology
The GCD comes from the Euclidean algorithm. The LCM uses the identity LCM(a, b) = a × b ÷ GCD(a, b). For three or more numbers both are folded in pairs: GCD(a, b, c) = GCD(GCD(a, b), c), and likewise for the LCM. This GCD calculator takes 2 to 10 integers of up to 10^15 in absolute value, works in exact integer arithmetic, and can show the prime factorization of each input up to 10^12.
Frequently asked questions
- How do you find the GCD of two numbers?
- Divide the larger by the smaller and keep the remainder. Replace the pair with the smaller number and the remainder, and repeat until the remainder is 0. The last non-zero remainder is the GCD. For 48 and 18: 48 = 2 × 18 + 12, 18 = 1 × 12 + 6, 12 = 2 × 6 + 0, so the GCD is 6.
- Are GCD, HCF and GCF the same thing?
- Yes. Greatest common divisor, highest common factor and greatest common factor are three names for the same number.
- How do you get the LCM from the GCD?
- LCM(a, b) = a × b ÷ GCD(a, b). For 12 and 18 that is 216 ÷ 6 = 36. The shortcut is for two numbers; with three or more, take the LCM of the first two, then the LCM of that result and the next number.
- How do you find the GCD and LCM by prime factorization?
- 12 = 2² × 3 and 18 = 2 × 3². The GCD takes the lowest power of each prime the numbers share: 2 × 3 = 6. The LCM takes the highest power of every prime: 2² × 3² = 36.
- What does a GCD of 1 mean?
- The numbers share no factor other than 1 and are called coprime. 17 and 5 are coprime, so their LCM is their product, 85.
- Can I enter zero, negative numbers or decimals?
- Zero is rejected. A negative number is treated as its absolute value. Decimals are rejected too, because GCD and LCM are only defined for whole numbers.
Related Tools
View all toolsPrime Factorization Calculator
Prime factorization of any whole number from 2 to 999,999,999,999, shown as a product and as powers: 360 = 2^3 × 3^2 × 5.
Quadratic Equation Solver
Solve ax² + bx + c = 0 for real or complex roots, with the discriminant, vertex, axis of symmetry, step list and a parabola plot.
Matrix Calculator
Add, subtract and multiply matrices up to 10 × 10, or get the determinant, inverse, transpose, rank and row-reduced form. Answers are exact fractions.
Standard Deviation
Standard deviation calculator for a list of numbers: population σ and sample s side by side, both variances, plus mean, median, minimum, maximum, range and sum.
Percentage Calculator
Percentage calculator for seven questions: X% of Y, X is what % of Y, percent change, percent difference, X is Y% of what, and a percent increase or decrease.
Prime Number Checker
Type a whole number below 3.3 × 10^24 to see whether it is prime. A composite gets its smallest prime factor, and the five primes on either side are listed.