GCF and LCM Calculator
Calculate GCF and LCM together — with prime factorizations and step-by-step working.
📊 What are GCF and LCM?
The GCF (Greatest Common Factor), also known as GCD (Greatest Common Divisor) or HCF (Highest Common Factor), is the largest positive integer that divides all given numbers exactly with no remainder.
The LCM (Least Common Multiple) is the smallest positive integer that is a multiple of all given numbers.
These two concepts are among the most important in elementary number theory and have wide practical applications — from simplifying fractions and solving word problems to scheduling, music theory, and cryptography.
The key relationship: For any two positive integers a and b: GCF(a, b) × LCM(a, b) = a × b
This identity means you only need to calculate one of them to find the other: LCM = (a × b) ÷ GCF.
📐 Formula
GCF via Euclidean algorithm: GCF(a, b) = GCF(b, a mod b), repeated until remainder = 0
GCF via prime factorization: Find all prime factors. GCF = product of shared primes at their lowest exponent.
LCM via prime factorization: LCM = product of all primes (from any number) at their highest exponent.
LCM from GCF: LCM(a, b) = (a × b) ÷ GCF(a, b)
| Concept | Short Rule | Example (12, 18) |
|---|---|---|
| GCF | Shared primes, lowest power | 2¹ × 3¹ = 6 |
| LCM | All primes, highest power | 2² × 3² = 36 |
| Relationship | GCF × LCM = a × b | 6 × 36 = 216 = 12 × 18 ✓ |
📖 How to Use
Steps to Calculate
💡 Example Calculations
Example 1 — Two numbers: 12 and 18
Find the GCF and LCM of 12 and 18.
Example 2 — Three numbers: 12, 18, 24
Find the GCF and LCM of 12, 18, and 24.
Example 3 — Coprime numbers: 8 and 9
Find the GCF and LCM of 8 and 9.
Example 4 — Simplifying a fraction using GCF
Simplify 36/48.
Example 5 — Adding fractions using LCM
Example 6 — Scheduling problem
Bus A departs every 12 minutes, Bus B every 18 minutes. When do they next depart together?
❓ Frequently Asked Questions
🔗 Related Calculators
What is the difference between GCF and LCM?
The GCF (Greatest Common Factor), also called GCD (Greatest Common Divisor) or HCF (Highest Common Factor), is the largest positive integer that divides all the given numbers without leaving a remainder. The LCM (Least Common Multiple) is the smallest positive integer that is divisible by all the given numbers. For example, GCF(12, 18) = 6 and LCM(12, 18) = 36. GCF is used to simplify fractions; LCM is used to find common denominators.
How do you find the GCF using prime factorization?
Write each number as a product of prime factors. The GCF is the product of all prime factors that appear in every number, using the lowest exponent that appears. For GCF(24, 36): 24 = 2³ × 3 and 36 = 2² × 3². Both have 2 and 3. Lowest power of 2 is 2² = 4; lowest power of 3 is 3¹ = 3. GCF = 4 × 3 = 12.
How do you find the LCM using prime factorization?
Write each number as a product of prime factors. The LCM is the product of all prime factors that appear in any number, using the highest exponent that appears. For LCM(12, 18): 12 = 2² × 3 and 18 = 2 × 3². Highest power of 2 is 2² = 4; highest power of 3 is 3² = 9. LCM = 4 × 9 = 36.
What is the Euclidean algorithm for finding GCF?
The Euclidean algorithm is an efficient method: divide the larger number by the smaller, take the remainder, then repeat. GCF equals the last non-zero remainder. Example: GCF(48, 18). Step 1: 48 = 2 × 18 + 12. Step 2: 18 = 1 × 12 + 6. Step 3: 12 = 2 × 6 + 0. GCF = 6 (the last non-zero remainder). This works because GCF(a, b) = GCF(b, a mod b).
What is the relationship between GCF and LCM?
For any two positive integers a and b: GCF(a, b) × LCM(a, b) = a × b. This is a key identity. It means you only need to find one of GCF or LCM and can derive the other: LCM(a, b) = a × b ÷ GCF(a, b). For example, GCF(4, 6) = 2 and LCM(4, 6) = 12. Check: 2 × 12 = 24 = 4 × 6. Note: this identity applies to exactly two numbers; for three or more, it does not hold.
What does it mean if GCF equals 1?
If GCF(a, b) = 1, the numbers are called coprime or relatively prime. They share no common prime factors. Their LCM equals their product: LCM = a × b. For example, GCF(8, 9) = 1 (8 = 2³, 9 = 3²), so LCM(8, 9) = 72. Any two consecutive integers are always coprime. Any prime number is coprime with any other number that is not its multiple.
How is GCF used to simplify fractions?
To reduce a fraction to lowest terms, divide both numerator and denominator by their GCF. For 36/48: GCF(36, 48) = 12. Divide both by 12: 36/12 = 3, 48/12 = 4. The simplified fraction is 3/4. This works because dividing numerator and denominator by the same non-zero number does not change the value of the fraction.
How is LCM used to add fractions?
To add fractions with different denominators, find the LCD (Least Common Denominator), which equals the LCM of the denominators. For 1/4 + 5/6: LCM(4, 6) = 12. Convert: 1/4 = 3/12 and 5/6 = 10/12. Add: 3/12 + 10/12 = 13/12 = 1 1/12. Without the LCM, you would use a larger common denominator (like 24), creating bigger numbers and requiring extra simplification at the end.
Can GCF or LCM of more than two numbers be calculated?
Yes. For multiple numbers, compute iteratively. GCF(a, b, c) = GCF(GCF(a, b), c). Similarly, LCM(a, b, c) = LCM(LCM(a, b), c). The prime factorization method also generalises: for GCF, take the lowest power of primes common to all numbers; for LCM, take the highest power of any prime appearing in any number. Our calculator handles 2 to 8 numbers at once.
What is the GCF of 0 and a number?
By convention, GCF(0, n) = n for any positive integer n. This is because every integer divides 0 (0 ÷ n = 0 with no remainder for any non-zero n). Calculators and algorithms typically require positive inputs; our calculator enforces this. The Euclidean algorithm handles it by considering that all positive integers divide zero, making the last non-zero number (n) the GCF.
What is the GCF useful for in real life?
GCF has several practical applications: (1) Simplifying fractions to lowest terms for cooking or measurement conversions. (2) Dividing objects into equal groups — GCF(36, 48) = 12 means you can make 12 identical groups using 36 and 48 items, with 3 and 4 items respectively. (3) Solving gear ratio and scheduling problems. (4) Cryptography, where coprime numbers are used in RSA encryption algorithms.
What is the LCM useful for in real life?
LCM appears frequently in scheduling and synchronisation problems. If Event A occurs every 4 days and Event B every 6 days, they next coincide after LCM(4, 6) = 12 days. In music, LCM determines when rhythmic patterns align. In electronics, it helps synchronise signals with different frequencies. In cooking, if one recipe serves 4 and another serves 6, LCM(4, 6) = 12 servings is the minimum to make equal batches of both.
How do you find GCF by listing factors?
For small numbers, you can list all factors of each number and find the largest one in common. Factors of 12: 1, 2, 3, 4, 6, 12. Factors of 18: 1, 2, 3, 6, 9, 18. Common factors: 1, 2, 3, 6. Greatest = 6. This method works for small numbers but becomes impractical for large ones. The Euclidean algorithm or prime factorization is more efficient for larger values.