What is an LCM and GCD calculator?
This LCM calculator finds the least common multiple (LCM) and the greatest common divisor (GCD) of two, three, four or more whole numbers in one go. The GCD is also called the HCF (highest common factor) in Indian textbooks and the GCF (greatest common factor) in American ones – they are the same number. Type your numbers and the calculator shows the prime factorization of each number, then builds the LCM and HCF from those factors, so it doubles as an LCM calculator with steps for homework and exam practice.
What is LCM in maths?
The LCM of two or more numbers is the smallest positive number that every one of them divides into exactly. The multiples of 4 are 4, 8, 12, 16, 20, 24… and the multiples of 6 are 6, 12, 18, 24… The smallest multiple they share is 12, so the LCM of 4 and 6 is 12. The LCM is what you need to add fractions with different denominators (it becomes the least common denominator), to find when repeating events line up, and to solve "bells ring together" style problems.
What is HCF / GCD?
The HCF or GCD is the largest number that divides every number in the list without a remainder. The factors of 12 are 1, 2, 3, 4, 6, 12 and the factors of 18 are 1, 2, 3, 6, 9, 18, so the HCF of 12 and 18 is 6. The HCF is used to simplify fractions and ratios and to cut things into the largest equal pieces.
How to use the LCM calculator
- Type two or more whole numbers separated by commas or spaces – up to 20 numbers.
- The result shows the LCM and the GCD/HCF straight away.
- Open the prime factorization table to see each number broken into primes, and how the LCM and HCF are built from them.
How to calculate LCM using prime factorization
- Break each number into prime factors. For the default example 12, 18 and 30: 12 = 2² × 3, 18 = 2 × 3², 30 = 2 × 3 × 5.
- For the LCM, take every prime that appears, with its highest power: 2², 3² and 5. LCM = 4 × 9 × 5 = 180.
- For the HCF, take only the primes common to all numbers, with their lowest power: 2¹ and 3¹. HCF = 2 × 3 = 6.
LCM = product of each prime at its highest power · HCF = product of common primes at their lowest power
LCM formula for two numbers
For exactly two numbers there is a handy shortcut linking LCM and HCF:
LCM(a, b) = (a × b) ÷ HCF(a, b)
Example – LCM of 12 and 18: HCF = 6, so LCM = 12 × 18 ÷ 6 = 216 ÷ 6 = 36. The calculator checks this identity for every pair: LCM × HCF = a × b (36 × 6 = 216). This formula does not work for three or more numbers – use prime factorization or apply it in pairs: LCM(a, b, c) = LCM(LCM(a, b), c).
LCM by the division (ladder) method
The division method, also called the ladder method, is the fastest way to calculate LCM by hand for several numbers:
- Write the numbers in a row: 12, 18, 30.
- Divide by a prime that divides at least two of them, and bring down any number that is not divisible: ÷2 → 6, 9, 15.
- Repeat: ÷3 → 2, 3, 5.
- Stop when no prime divides two or more numbers. Multiply all the divisors and the remaining numbers: 2 × 3 × 2 × 3 × 5 = 180.
How to calculate HCF: the Euclidean algorithm
For large numbers, Euclid's method is quicker than factorizing. 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 HCF. For 252 and 105: 252 = 2 × 105 + 42, 105 = 2 × 42 + 21, 42 = 2 × 21 + 0, so the HCF is 21. This is also how computers – and code in Python (math.gcd, math.lcm) or Java – calculate the GCD.
LCM and HCF examples
| Numbers | Prime factors | LCM | HCF |
|---|---|---|---|
| 4, 6 | 2², 2 × 3 | 12 | 2 |
| 8, 12 | 2³, 2² × 3 | 24 | 4 |
| 12, 18 | 2² × 3, 2 × 3² | 36 | 6 |
| 15, 25 | 3 × 5, 5² | 75 | 5 |
| 12, 18, 30 | 2² × 3, 2 × 3², 2 × 3 × 5 | 180 | 6 |
| 8, 9, 25 | 2³, 3², 5² | 1,800 | 1 |
| 6, 10, 14, 15 | 2 × 3, 2 × 5, 2 × 7, 3 × 5 | 210 | 1 |
When the HCF is 1 the numbers are called co-prime, and for two co-prime numbers the LCM is simply their product (8 and 9 → 72).
LCM of fractions
To calculate the LCM of fractions, use: LCM of fractions = LCM of numerators ÷ HCF of denominators. For 2/3 and 4/9: LCM(2, 4) = 4 and HCF(3, 9) = 3, so the LCM is 4/3. Similarly, HCF of fractions = HCF of numerators ÷ LCM of denominators. For everyday fraction arithmetic – adding 5/12 and 7/18 – you need the LCM of the denominators (36) as the common denominator; the fraction calculator does this for you with steps.
Where LCM and HCF are used
- Timing problems (LCM): three bells ring every 12, 18 and 30 minutes. They ring together again after 180 minutes – 3 hours.
- Tiling and cutting (HCF): the largest square tile that fits a 12 m × 18 m floor exactly is 6 m.
- Grouping (HCF): 30 apples and 18 oranges packed into identical bags with nothing left over: at most 6 bags.
- Ratios: dividing both parts of a ratio by the HCF gives its simplest form – see the ratio calculator.
How to calculate LCM fast
- If one number divides the other, the bigger number is the LCM: LCM(6, 24) = 24.
- If the numbers are co-prime, multiply them: LCM(7, 10) = 70.
- Otherwise, list multiples of the largest number and stop at the first one the others divide: for 4 and 6, check 6, 12 → 12.
- To check whether a number is prime before factorizing, use the prime number calculator.
LCM calculator formula and LCM calculation formula
The least common multiple formula this LCM calculator uses for two numbers is LCM(a, b) = a × b ÷ HCF(a, b). For more numbers, it applies the LCM calculation formula step by step: LCM(a, b, c) = LCM(LCM(a, b), c). With prime factors, the LCM formula is: take every prime that appears and raise it to its highest power.
LCM calculation example with solution
What is an example of LCM? Take 12, 18 and 30 (the default input). Prime factors: 12 = 2² × 3, 18 = 2 × 3², 30 = 2 × 3 × 5. Highest powers: 2², 3², 5. LCM = 4 × 9 × 5 = 180. Common primes at their lowest powers give the HCF: 2 × 3 = 6. This LCM calculator with solution shows the same steps for your numbers.
LCM calculator using prime factorization and exponents
When numbers are written with exponents, a least common multiple calculator with exponents simply compares powers. LCM of 2³ × 3 and 2² × 3² × 5 is 2³ × 3² × 5 = 360. The LCM calculator with exponents rule: keep the highest exponent of each prime; for HCF keep the lowest.
LCM calculator by division method (ladder method)
The LCM calculator division method, also called the ladder method, divides all numbers by a prime that divides at least one of them, carrying down any number that does not divide.
2 | 12 18 30 3 | 6 9 15 3 | 2 3 5 5 | 2 1 5 2 | 2 1 1 | 1 1 1
Multiply the divisors on the left: 2 × 3 × 3 × 5 × 2 = 180.
LCM calculator technique and trick for fast answers
- Multiplication trick: for two numbers, the LCM calculator multiplication shortcut is a × b ÷ HCF. 21 and 6: 126 ÷ 3 = 42.
- Co-prime trick: if two numbers share no factor, the LCM is their product: LCM(8, 9) = 72.
- Multiples trick: list multiples of the largest number until one divides by the others: 15, 30, 45, 60 → LCM(4, 6, 15) = 60.
- Factor trick: if one number divides the other, the larger one is the LCM: LCM(7, 28) = 28.
LCM calculator for 4 numbers
Enter all four numbers separated by commas. For 4, 6, 8 and 10: LCM(4, 6) = 12, LCM(12, 8) = 24, LCM(24, 10) = 120.
LCM calculator for fractions and decimal numbers
An LCM calculator for fractions uses: LCM of fractions = LCM of numerators ÷ HCF of denominators. For 2/3 and 4/9, LCM(2, 4) = 4 and HCF(3, 9) = 3, so the LCM is 4/3. To use the LCM calculator with fractions for adding, you usually want the LCM of the denominators instead: 3 and 9 give 9.
For an LCM calculator for decimal numbers, multiply every number by the same power of 10 to make them whole, find the LCM, then divide back. For 0.6 and 0.9: LCM(6, 9) = 18, so the LCM is 1.8.
LCM calculator for algebraic expressions with variables
An LCM calculator for algebra treats each variable like a prime. For 6x²y and 4xy³: LCM(6, 4) = 12, highest power of x is x², of y is y³, so the LCM is 12x²y³. The same rule makes an LCM calculator with variables work for polynomials: LCM of (x − 1)(x + 2) and (x + 2)² is (x − 1)(x + 2)². An LCM equation calculator question such as "LCM of n and 12 is 36" is solved by listing divisors of 36 that fit.
Calculator: LCM and GCF together
GCF (greatest common factor), GCD and HCF are three names for the same thing. This calculator gives the LCM and GCF together, and for two numbers you can check them with LCM × GCF = a × b: 12 × 18 = 216 = 36 × 6.
LCM calculator in Hindi and Tamil
An LCM calculator in Hindi is called an LCM ka calculator; LCM is laghuttam samapavartya (लघुत्तम समापवर्त्य) and HCF is mahattam samapavartak. An LCM calculator in Tamil is for meechiru pothu madangu (மீ.சி.ம.). The method is the same in every language.
LCM calculator in Python and LCM calculation in Java
An LCM calculator in Python can use the built-in math module: import math; math.lcm(12, 18, 30) returns 180 (Python 3.9+). For LCM calculation in Java, use Euclid's algorithm: long gcd(long a, long b) { return b == 0 ? a : gcd(b, a % b); } and then lcm = a / gcd(a, b) * b. Dividing before multiplying avoids overflow.
Frequently asked questions
How do I calculate LCM?
Write each number as a product of prime factors, then multiply every prime that appears using its highest power. For 12 = 2² × 3 and 18 = 2 × 3², the LCM is 2² × 3² = 36.
What is the difference between LCM and HCF?
The LCM is the smallest number that all the given numbers divide into. The HCF (GCD or GCF) is the largest number that divides all of them. For 12 and 18, the LCM is 36 and the HCF is 6.
What is the LCM of 4 and 6?
The LCM of 4 and 6 is 12, because 12 is the smallest number that both 4 and 6 divide into exactly. Their HCF is 2.
What is the LCM of 12 and 18?
The LCM of 12 and 18 is 36 and their HCF is 6. You can check it: 36 × 6 = 216 = 12 × 18.
How do I find the LCM of three numbers?
Factorize all three numbers and take each prime at its highest power, or find the LCM of the first two and then the LCM of that result with the third. The LCM of 12, 18 and 30 is 180.
Are GCD, GCF and HCF the same?
Yes. Greatest common divisor, greatest common factor and highest common factor are three names for the same number.
Is this LCM and GCD calculator free?
Yes. The LCM and HCF calculator is free, shows prime factorization steps and works for up to 20 numbers at a time.
What is the formula for LCM?
LCM(a, b) = a × b ÷ HCF(a, b). For more numbers, find the LCM of two, then of that result and the next number.
How do I find the LCM of fractions?
Divide the LCM of the numerators by the HCF of the denominators. LCM of 1/2 and 3/4 is 3/2.
Last updated 2026-09-18