Last updated March 2026

LCM & GCF Calculator

Find the Least Common Multiple (LCM) and Greatest Common Factor (GCF) of two or more numbers with prime factorization.

What Are GCF and LCM?

The Greatest Common Factor (GCF) and the Least Common Multiple (LCM) are two fundamental concepts in number theory that appear throughout mathematics, from elementary arithmetic to advanced algebra. Understanding these concepts is essential for simplifying fractions, finding common denominators, solving word problems, and working with ratios and proportions.

The Greatest Common Factor (also called the Greatest Common Divisor, or GCD) of two or more numbers is the largest positive integer that divides evenly into all of them. For example, the factors of 24 are 1, 2, 3, 4, 6, 8, 12, and 24, and the factors of 36 are 1, 2, 3, 4, 6, 9, 12, 18, and 36. The common factors are 1, 2, 3, 4, 6, and 12, so the GCF of 24 and 36 is 12. In practical terms, the GCF answers the question: "What is the largest number I can divide both quantities by evenly?"

The Least Common Multiple of two or more numbers is the smallest positive integer that is a multiple of each of them. The multiples of 4 are 4, 8, 12, 16, 20, 24, and so on. The multiples of 6 are 6, 12, 18, 24, 30, and so on. The common multiples are 12, 24, 36, and so on, so the LCM of 4 and 6 is 12. In practical terms, the LCM answers the question: "What is the smallest number that all these quantities divide into evenly?"

How to Find the GCF

There are three main methods for finding the GCF: listing factors, prime factorization, and the Euclidean algorithm. Each method has its advantages depending on the size of the numbers involved.

Method 1: Listing Factors

List all factors of each number, identify the common factors, and choose the largest one. This method is straightforward for small numbers but becomes impractical for large numbers.

Example: Find the GCF of 48 and 60.

Method 2: Prime Factorization

Factor each number into its prime factors, then multiply together the common prime factors using the lowest power of each.

48 = 24 × 3
60 = 22 × 3 × 5
GCF = 22 × 3 = 12

The prime factorization method is systematic and works well for numbers of any size. For the GCF, you take the minimum power of each prime that appears in all factorizations. Prime 2 appears with power 4 in 48 and power 2 in 60, so take 2². Prime 3 appears with power 1 in both, so take 3¹. Prime 5 appears only in 60, not in both, so it is excluded. GCF = 4 × 3 = 12.

Method 3: The Euclidean Algorithm

The Euclidean algorithm is the most efficient method, especially for large numbers. It is based on the principle that GCF(a, b) = GCF(b, a mod b), where "mod" means the remainder after division. You repeatedly replace the larger number with the remainder until the remainder is zero. The last non-zero remainder is the GCF.

GCF(48, 60):
60 = 1 × 48 + 12
48 = 4 × 12 + 0
GCF = 12

The Euclidean algorithm is remarkably efficient. It was described by Euclid around 300 BCE and remains one of the oldest algorithms still in active use today. For very large numbers (hundreds of digits, as in cryptography), the Euclidean algorithm runs in a fraction of a second, while listing factors would be computationally infeasible. This calculator uses the Euclidean algorithm internally for its speed and reliability.

How to Find the LCM

The LCM can be found using prime factorization or by using the relationship between GCF and LCM.

Method 1: Prime Factorization

Factor each number into primes, then multiply together the highest power of each prime that appears in any of the factorizations.

24 = 23 × 3
36 = 22 × 32
LCM = 23 × 32 = 8 × 9 = 72

For the LCM, you take the maximum power of each prime across all factorizations. This ensures that the LCM is divisible by each original number. Prime 2 has maximum power 3 (from 24), and prime 3 has maximum power 2 (from 36), so LCM = 8 × 9 = 72.

Method 2: Using the GCF-LCM Relationship

LCM(a, b) = |a × b| / GCF(a, b)

This elegant formula connects the GCF and LCM. Since the GCF can be found quickly using the Euclidean algorithm, this provides an efficient way to compute the LCM without performing prime factorization. For 24 and 36: GCF = 12, so LCM = (24 × 36) / 12 = 864 / 12 = 72. This is the method used by this calculator for speed, combined with prime factorization displayed for educational purposes.

GCF and LCM of Multiple Numbers

To find the GCF or LCM of more than two numbers, apply the operation iteratively. For the GCF of three numbers a, b, and c: GCF(a, b, c) = GCF(GCF(a, b), c). The same approach works for LCM: LCM(a, b, c) = LCM(LCM(a, b), c). This calculator supports multiple numbers using this iterative approach.

Example: Find the GCF and LCM of 12, 18, and 24.

Real-World Applications

GCF and LCM are not just abstract mathematical concepts; they have practical applications in everyday life and various professional fields.

Simplifying Fractions (GCF)

The most common use of the GCF is simplifying fractions. To reduce a fraction to its lowest terms, divide both the numerator and denominator by their GCF. For example, the fraction 48/60 can be simplified by dividing both parts by GCF(48, 60) = 12, giving 4/5. Without finding the GCF, you might simplify in multiple steps (dividing by 2, then 2, then 3), but using the GCF gives you the fully reduced fraction in a single step.

Finding Common Denominators (LCM)

Adding or subtracting fractions requires a common denominator, and the least common denominator is the LCM of the individual denominators. To add 5/12 + 7/18, find LCM(12, 18) = 36. Convert: 5/12 = 15/36 and 7/18 = 14/36. The sum is 15/36 + 14/36 = 29/36. Using the LCM (rather than just any common multiple) keeps the numbers as small as possible and minimizes the need for further simplification.

Scheduling and Cycles (LCM)

The LCM is useful whenever you need to find when periodic events will coincide. If one traffic light cycles every 45 seconds and another every 60 seconds, they will both be green at the same time every LCM(45, 60) = 180 seconds, or 3 minutes. If one employee has every 3rd day off and another has every 5th day off, they share a day off every LCM(3, 5) = 15 days. Gear ratios, planetary alignments, and medication schedules all involve LCM calculations.

Dividing Groups Evenly (GCF)

The GCF helps when you need to divide items into equal groups with no remainders. If a teacher has 24 pencils and 36 erasers to distribute equally among groups of students, the largest number of groups possible is GCF(24, 36) = 12. Each group receives 2 pencils and 3 erasers. Event planners, manufacturers packing items into boxes, and farmers dividing harvests all use GCF-based reasoning.

Cryptography and Computer Science

The GCF (via the Euclidean algorithm) is fundamental to modern cryptography. The RSA encryption algorithm, which secures most internet communications, relies heavily on GCF calculations during key generation. Two numbers are said to be coprime (or relatively prime) if their GCF is 1, and this property is essential for generating secure encryption keys. The extended Euclidean algorithm, which finds not only the GCF but also the coefficients that express it as a linear combination of the original numbers, is used to compute modular multiplicative inverses, a critical operation in RSA decryption.

Prime Factorization

Prime factorization is the process of expressing a number as a product of prime numbers. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself (2, 3, 5, 7, 11, 13, ...). The Fundamental Theorem of Arithmetic states that every integer greater than 1 has a unique prime factorization (up to the order of the factors).

To find the prime factorization of a number, repeatedly divide by the smallest possible prime:

So 120 = 2³ × 3 × 5. This calculator displays the prime factorization of each input number in both expanded form (2 × 2 × 2 × 3 × 5) and exponential form (2³ × 3 × 5). Understanding prime factorization is the key to mastering GCF and LCM calculations, as well as many other areas of mathematics including divisibility rules, modular arithmetic, and number theory.

Common Mistakes to Avoid

Frequently Asked Questions

What is the difference between GCF and LCM?

The Greatest Common Factor (GCF) is the largest number that divides evenly into all given numbers. The Least Common Multiple (LCM) is the smallest number that all given numbers divide into evenly. The GCF is used for simplifying fractions and dividing into equal groups, while the LCM is used for finding common denominators and synchronizing periodic events. For any two numbers, the GCF is always less than or equal to the smallest number, and the LCM is always greater than or equal to the largest number.

How do you find the LCM using prime factorization?

First, express each number as a product of prime factors with exponents. Then, for each prime that appears in any factorization, take the highest exponent. Multiply these together to get the LCM. For example, 12 = 2² × 3 and 18 = 2 × 3². The highest power of 2 is 2² and the highest power of 3 is 3², so LCM = 2² × 3² = 4 × 9 = 36. This method works for any number of inputs.

What is the relationship between GCF and LCM of two numbers?

For any two positive integers a and b, the product of their GCF and LCM equals the product of the two numbers: GCF(a, b) × LCM(a, b) = a × b. This means LCM(a, b) = (a × b) / GCF(a, b). For example, for 12 and 18: GCF = 6, so LCM = (12 × 18) / 6 = 216 / 6 = 36. This formula provides a fast way to calculate the LCM once you know the GCF, especially when combined with the efficient Euclidean algorithm for finding the GCF.

Can the GCF be larger than one of the numbers?

No. The GCF of two or more numbers can never be larger than the smallest number in the group, because a factor of a number cannot exceed the number itself. The GCF equals the smallest number only when the smallest number divides evenly into all the other numbers. For example, GCF(6, 12, 18) = 6. In the extreme case where all numbers are equal, the GCF equals that number: GCF(8, 8, 8) = 8.

What does it mean if the GCF of two numbers is 1?

If the GCF of two numbers is 1, the numbers are called coprime (or relatively prime). This means they share no common factors other than 1. Examples include 8 and 15, 7 and 20, and any two distinct prime numbers. Coprime numbers have an important property: their LCM equals their product (since LCM = a × b / GCF = a × b / 1). Coprimality is a key concept in number theory and is fundamental to RSA encryption and modular arithmetic.

Related Calculators