OnSumoTools

GCF and LCM Calculator

Find the Greatest Common Factor and Least Common Multiple of any two positive integers, with full prime factorization and step-by-step working.

This calculator finds the Greatest Common Factor (GCF) and Least Common Multiple (LCM) of any two positive integers. Enter both numbers and get both answers instantly, along with prime factorization and the Euclidean algorithm steps so you can see how the answer was reached. Use it for simplifying fractions, finding common denominators, scheduling problems, or any time you need to know what two numbers share or how they combine.

How this tool works

Enter two positive whole numbers. The tool runs the Euclidean algorithm to find the GCF: it repeatedly divides the larger number by the smaller, takes the remainder, and repeats until the remainder is zero. The last non-zero remainder is the GCF. The LCM is then found using the relationship LCM(a, b) = (a × b) ÷ GCF(a, b). Toggle Show steps to see the full prime factorization and each division step.

Worked examples

  • Simplifying a fraction

    You want to reduce 48/36 to lowest terms. GCF(48, 36) = 12. Divide both by 12: 48/12 = 4 and 36/12 = 3. The simplified fraction is 4/3.

  • Finding a common denominator

    To add 1/12 and 1/18, you need a common denominator. LCM(12, 18) = 36. Convert: 1/12 = 3/36 and 1/18 = 2/36. Add them: 3/36 + 2/36 = 5/36.

  • Scheduling problem

    Two buses leave a stop every 8 and 12 minutes. LCM(8, 12) = 24. They will next depart together in 24 minutes.

Frequently asked questions

  • What is the Greatest Common Factor (GCF)?

    The Greatest Common Factor, also called the Greatest Common Divisor (GCD), is the largest positive integer that divides both numbers without leaving a remainder. For 12 and 18, the GCF is 6 because 6 is the largest number that goes into both 12 and 18 evenly.

  • What is the Least Common Multiple (LCM)?

    The Least Common Multiple is the smallest positive integer that is divisible by both numbers. For 4 and 6, the LCM is 12 because 12 is the smallest number that both 4 and 6 divide into evenly. The LCM is used when finding a common denominator for fractions.

  • What is the Euclidean algorithm?

    The Euclidean algorithm is an efficient method for computing the GCF. It works by repeatedly replacing the larger number with the remainder when the larger is divided by the smaller. When the remainder reaches zero, the last non-zero number is the GCF. For GCF(48, 18): 48 = 2×18 + 12, then 18 = 1×12 + 6, then 12 = 2×6 + 0. The GCF is 6.

  • How do GCF and LCM relate to each other?

    For any two positive integers a and b, GCF(a, b) × LCM(a, b) = a × b. This means once you know the GCF, you can always find the LCM with LCM = (a × b) ÷ GCF. For 12 and 18: GCF = 6, so LCM = (12 × 18) ÷ 6 = 216 ÷ 6 = 36.

  • What does it mean when the GCF equals 1?

    When GCF(a, b) = 1, the two numbers are called coprime or relatively prime. They share no common factors other than 1. For example, 8 and 15 are coprime: GCF(8, 15) = 1. Coprime numbers have an LCM equal to their product: LCM(8, 15) = 120.

  • How is GCF used to simplify fractions?

    To simplify a fraction, divide both the numerator and denominator by their GCF. For 24/36, the GCF is 12. Divide both: 24÷12 = 2 and 36÷12 = 3. The simplified fraction is 2/3. Dividing by the GCF gives the fraction in lowest terms in one step.

  • What is prime factorization and how does it find the GCF?

    Prime factorization breaks a number into its prime factors. For GCF, find the prime factorization of both numbers and take the lowest power of each shared prime. For 36 = 2² × 3² and 48 = 2⁴ × 3, the shared primes are 2 and 3. Take 2¹ and 3¹, giving GCF = 2 × 3 = 6. Wait — the lower exponent of 2 is min(2,4) = 2 and min(2,1) = 1 for 3. GCF = 2² × 3 = 12.

  • Can these methods be extended to more than two numbers?

    Yes. To find the GCF of three or more numbers, compute GCF(a, b) first, then compute GCF(result, c), and so on. The same chain approach works for LCM. For example, GCF(12, 18, 24) = GCF(GCF(12, 18), 24) = GCF(6, 24) = 6.

Related tools

Two numbers, two useful answers

The greatest common factor is the biggest number that divides both of your numbers with nothing left over. The least common multiple is the smallest number that both of them divide into. They sound alike and do opposite jobs.

Type in two whole numbers and the calculator shows both, along with the working. You see the prime factors and the steps of the Euclidean method, so you can follow the logic and not just copy an answer.

Finding the GCF by prime factors

Break each number into primes. For 36 that's 2 x 2 x 3 x 3. For 48 it's 2 x 2 x 2 x 2 x 3. Take the primes they share, with the lower count of each: two 2s and one 3. Multiply and you get 12.

The LCM goes the other way. Take every prime that shows up, with the higher count of each. That's four 2s and two 3s, which is 144.

The Euclidean algorithm

Prime factoring gets slow for big numbers. Euclid's method is far faster. Divide the larger number by the smaller, keep the remainder, and repeat with the smaller number and that remainder. When the remainder hits zero, the last divisor is the GCF.

For 48 and 36: 48 divided by 36 leaves 12. Then 36 divided by 12 leaves 0. So the GCF is 12. It's over in two lines, and it has been in use for more than two thousand years.

How GCF and LCM connect

Multiply the two numbers together and you get the same result as multiplying their GCF and LCM. In symbols, a x b = GCF x LCM. It's a handy check, and it's also a quick way to get the LCM once you have the GCF: divide a x b by the GCF.

If the GCF is 1, the numbers are called coprime. They share no factors, and their LCM is just their product. 8 and 15 are a good example.

Where you'd use them

GCF simplifies fractions. To reduce 36/48, divide top and bottom by 12 and get 3/4. LCM finds a common denominator when you add fractions with different bottoms, like 1/6 plus 1/8, where 24 works.

It also shows up in scheduling. If one bus comes every 12 minutes and another every 18, they meet together every 36 minutes. That's the LCM.

The tool works on two numbers at once. For three or more, find the GCF of the first two, then take the GCF of that result and the next number. Same idea for LCM. Everything runs in your browser.