GCF and LCM Calculator

Calculate GCF and LCM together — with prime factorizations and step-by-step working.

🔢 GCF and LCM Calculator

Separate numbers with commas. Whole numbers up to 1,000,000,000.

Greatest Common Factor (GCF)
Least Common Multiple (LCM)
Prime Factorizations
Prime Factor Method
Euclidean Algorithm (GCF Steps)

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)

ConceptShort RuleExample (12, 18)
GCFShared primes, lowest power2¹ × 3¹ = 6
LCMAll primes, highest power2² × 3² = 36
RelationshipGCF × LCM = a × b6 × 36 = 216 = 12 × 18 ✓

How to Use

  1. Enter 2 to 8 positive integers — type them separated by commas, e.g. 12, 18, 24.
  2. Press Calculate — both GCF and LCM are computed instantly.
  3. Read the results — GCF and LCM appear at the top; for two numbers, GCF × LCM = a × b is verified.
  4. Review prime factorizations — each number is broken into its prime factors with full exponent notation.
  5. Follow the steps — the Euclidean algorithm shows the GCF calculation step by step; the prime factor method shows how LCM is derived.

Example Calculations

Example 1 — Two numbers: 12 and 18 12 = 2² × 3; 18 = 2 × 3². GCF = 2¹ × 3¹ = 6. LCM = 2² × 3² = 36. Check: 6 × 36 = 216 = 12 × 18 ✓

Example 2 — Three numbers: 12, 18, 24 12 = 2² × 3; 18 = 2 × 3²; 24 = 2³ × 3. GCF = 2¹ × 3¹ = 6 (lowest exponents of shared primes 2 and 3). LCM = 2³ × 3² = 72 (highest exponents: 2³ and 3²).

Example 3 — Coprime numbers: 8 and 9 8 = 2³; 9 = 3². No common prime factors. GCF = 1. LCM = 2³ × 3² = 72 = 8 × 9. (For coprime numbers, LCM = product.)

Example 4 — Simplifying a fraction using GCF: Simplify 36/48. GCF(36, 48) = 12. Divide both by 12: 36/48 = 3/4.

Example 5 — Adding fractions using LCM: 1/4 + 5/6. LCM(4, 6) = 12. Convert: 3/12 + 10/12 = 13/12.

Example 6 — Scheduling problem: Two buses depart together. Bus A every 12 minutes, Bus B every 18 minutes. They next depart together after LCM(12, 18) = 36 minutes.

What is the difference between GCF and LCM?
The GCF (Greatest Common Factor), also called GCD or HCF, is the largest positive integer that divides all the given numbers without 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 means you only need to find one to 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 in this simple form.
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 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 fraction's value.
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. Using the LCM as the LCD keeps the numbers as small as possible and avoids extra simplification.
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 useful for in real life?
GCF has several practical applications: simplifying fractions to lowest terms; dividing objects into equal groups (GCF(36, 48) = 12 means you can make 12 identical groups); solving gear ratio and tile-fitting problems; and cryptography, where coprime numbers are fundamental to RSA encryption. In everyday cooking, GCF helps reduce recipe ratios — GCF(6, 9) = 3, so a 6:9 ratio simplifies to 2:3.
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, LCM helps scale recipes — if one recipe serves 4 and another serves 6, LCM(4, 6) = 12 gives the minimum batch size for whole servings of both.
How do you find GCF by listing factors?
For small numbers, list all factors of each and find the largest 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.