How to Find GCD and LCM: Prime Factors, the Euclidean Method and Solved Problems
Updated: November 6, 2026 · AracMerkezi
GCD and LCM are two basic concepts we meet from primary school on. They are used to simplify fractions, equalize denominators, and solve problems of the "when do they meet again" or "what is the longest piece in cm" type. This guide does not stop at repeating the two methods (prime factorization and the Euclidean algorithm); it shows which method is easier when, the trap to watch for with three numbers, and how to decide "GCD or LCM?" from the wording of a question. All results were calculated with Python and also checked by hand.
Definitions
- GCD (greatest common divisor): The largest number that divides two (or more) numbers with no remainder.
- LCM (least common multiple): The smallest positive number that is a multiple of two (or more) numbers.
A quick reminder: the GCD cannot be larger than the numbers, and the LCM cannot be smaller than the numbers. With these two rules you can immediately sanity-check a result.
Method 1: Prime factorization
Let's look at 180 and 252:
- 180 = 2² × 3² × 5
- 252 = 2² × 3² × 7
GCD: Multiply the common prime factors with their smallest exponents: 2² × 3² = 36.
LCM: Multiply all prime factors with their largest exponents: 2² × 3² × 5 × 7 = 1,260.
Check: 180 / 36 = 5 and 252 / 36 = 7; both divide evenly and 5 and 7 have no common divisor. 1,260 / 180 = 7 and 1,260 / 252 = 5; so 1,260 is a multiple of both.
Method 2: The Euclidean algorithm (for the GCD)
You divide the larger number by the smaller and take the remainder; you keep dividing the divisor by the remainder until the remainder is zero. The last divisor is the GCD. As numbers get larger, prime factorization gets harder, while Euclid finishes in a few steps. For 1,071 and 462:
- 1,071 = 2 × 462 + 147
- 462 = 3 × 147 + 21
- 147 = 7 × 21 + 0
The last divisor is 21, so GCD = 21. You find the LCM from the relationship: 1,071 × 462 / 21 = 23,562.
The relationship between GCD and LCM
For two numbers, the equality GCD × LCM = a × b holds. If the GCD is known, LCM = a × b / GCD. For 48 and 18 the GCD is 6 and the LCM is 48 × 18 / 6 = 144. Note: this relationship holds only for two numbers (see the trap below).
GCD and LCM of three numbers
For 12, 18 and 30 the factors are: 12 = 2² × 3, 18 = 2 × 3², 30 = 2 × 3 × 5. GCD = 2 × 3 = 6, LCM = 2² × 3² × 5 = 180. For these three numbers the rule "GCD × LCM = product" does not work: 12 × 18 × 30 = 6,480, yet 6 × 180 = 1,080. For three or more numbers, find the LCM with the factors or by combining two at a time, not with the relationship.
Solved examples
| Numbers | GCD | LCM |
|---|---|---|
| 24 and 36 | 12 | 72 |
| 15 and 20 | 5 | 60 |
| 7 and 9 (coprime) | 1 | 63 |
| 100 and 75 | 25 | 300 |
How is it used in problems?
Look for these cues in the wording: phrases such as "largest", "divide into equal pieces", "no leftover" point to the GCD; phrases such as "when again", "at least how many", "at the same time" point to the LCM.
Problem 1 (GCD): Square tiles are to be laid on a 360 cm × 240 cm floor without cutting. The largest tile side is GCD(360, 240) = 120 cm. The number of tiles is (360 / 120) × (240 / 120) = 3 × 2 = 6.
Problem 2 (LCM): Three buses leave the terminal every 4, 6 and 10 minutes respectively. For them to leave together again after leaving together, LCM(4, 6, 10) = 60 minutes is needed.
Problem 3 (two ropes): To cut ropes of 24 m and 36 m into equal pieces with no leftover, the GCD is 12; the longest piece is 12 m. Duty rota: for two people who take a turn every 6 days and every 8 days, the LCM is 24, so they land on the same day 24 days later.
Problem 4 (three bells): Three bells ring every 60, 90 and 150 seconds respectively and have just rung together. For them to ring together again, LCM(60, 90, 150) = 900 seconds is needed; that is 900 / 60 = 15 minutes. Note that you first kept the seconds in the same unit; if units get mixed, the LCM loses its meaning. In time problems, converting the result to minutes or hours at the very end is the safest way.
Problem 5 (forming groups): 48 boys and 36 girls will be divided into groups so that each group has the same number of boys and the same number of girls and nobody is left out. The maximum number of groups is GCD(48, 36) = 12; each group has 4 boys and 3 girls. The phrase "maximum groups" points to the GCD, and "equal distribution in each group" points to divisibility.
Use with fractions
- Addition: In 5/12 + 7/18, the LCM of the denominators is 36. 5/12 = 15/36 and 7/18 = 14/36; the sum is 29/36.
- Simplification: In the fraction 84/126, GCD(84, 126) = 42. Dividing numerator and denominator by 42 gives 2/3.
For more fraction examples see the guides Simplifying Fractions: GCD and Mixed Number Examples and How to Do Fraction Operations.
Common mistakes
- Mixing up the GCD and the LCM; asking "is this a splitting question or a repeating question?" often settles it.
- Forgetting that the GCD of coprime numbers is 1; in that case the LCM is the product of the two numbers.
- Taking the prime-factor exponents wrongly: the smaller exponent for the GCD, the larger for the LCM.
- Applying the two-number relationship to three numbers.
- In Euclid, using the quotient instead of the remainder; the new divisor is always the previous remainder.
Mini glossary
- Prime factor: The prime numbers that make up a number.
- Coprime: Numbers whose GCD is 1; neither has to be prime (8 and 9).
- Divides evenly: The remainder of the division is zero.
The GCD / LCM Calculator shows both for two positive integers. To see prime factors use the Prime Number Check and Prime Factorization tool, and for proportion questions the guide How to Calculate Ratio and Proportion.
Frequently asked questions
What is the relationship between GCD and LCM?
The product of two numbers equals the GCD times the LCM: a × b = GCD × LCM. This relationship does not hold for three or more numbers.
What is the GCD of coprime numbers?
It is 1; their LCM is the product of the two numbers. For example, for 7 and 9 the GCD is 1 and the LCM is 63.
Which method finds the GCD most easily?
Prime factorization is practical for small numbers and the Euclidean algorithm for large ones. For 1,071 and 462, Euclid gives 21 in three steps.
Tools mentioned in this guide
More guides
- How to Calculate Ratio and Proportion: Direct, Inverse and Compound Proportion with Solved Examples – How do you calculate ratio and proportion? Cross-multiplication for direct, inverse and compound proportion, with mixture and map-scale examples.
- How to Calculate an Exam Net Score: YKS, KPSS and LGS Net Calculation – How do you calculate net from right and wrong answers? The 4-wrongs rule, the 3-wrongs rule in LGS, blank-vs-guess math and subject-by-subject examples.
- How to Calculate the Midterm-Final Average: Weighted Grade Average and Passing Math – How do you calculate an average with a 40% midterm and 60% final? The weighted-average formula, a needed-final table, multi-component grades, thresholds.
- What Is the Difference Between Mean, Median and Mode? When to Use Which – What are the mean, median and mode? How they are calculated, the effect of outliers, salary and home price examples, when to use each, and common mistakes.
- What Is Standard Deviation and How Is It Calculated? Variance Explained With Examples – What are standard deviation and variance and how are they calculated? Population vs sample (n and n-1), a step-by-step example, interpretation and common mistakes.
Important note: Results are estimates based on published coefficients and guides and do not replace official results. For exact information, rely on announcements from ÖSYM, MEB, YÖK or your school.
This article is for general information only and is not legal, financial or medical advice. We are not an official institution.