Loading live prices...

LCM and GCF Calculator

Find the LCM and GCF of any two whole numbers in one step — enter the numbers and the calculator shows both answers at once, together with the prime factorization of each number. It runs entirely in your browser: free, instant, no sign-in.

Whole numbers greater than 0. Negative numbers are treated as their absolute value. Very large numbers (above about 1,000,000,000) may be slow to factor.

How the LCM and GCF calculator works

The calculator finds the GCF (greatest common factor) with the Euclidean algorithm: it repeatedly replaces the larger number by the remainder when divided by the smaller one, until the remainder is 0 — the last non-zero remainder is the GCF. For 12 and 18: 18 ÷ 12 leaves 6, then 12 ÷ 6 leaves 0, so the GCF is 6. The LCM (least common multiple) is then found from the GCF: LCM = (first number × second number) ÷ GCF. For 12 and 18 that is (12 × 18) ÷ 6 = 216 ÷ 6 = 36. The two answers are linked: GCF × LCM always equals the product of the two numbers (6 × 36 = 216 = 12 × 18). The calculator also breaks each number into its prime factors — 12 = 2² × 3 and 18 = 2 × 3² — which is the same answer reached the long way round: the GCF takes the lowest power of each shared prime, and the LCM takes the highest.

Two numbers can share more than you might think. 12 and 18 share the factors 1, 2, 3 and 6, and they share the multiples 36, 72, 108 and every multiple of 36 after that. The LCM and GCF Calculator finds both of those answers in one step: enter two whole numbers and it shows the GCF (greatest common factor) and the LCM (least common multiple) at the same time, together with the prime factorization of each number. It works for homework, for checking answers, and for the everyday jobs where the LCM or GCF actually comes up — timing two things to line up, cutting something into equal pieces, or adding fractions with different denominators.

The calculation is exact, not an estimate, because it uses the Euclidean algorithm for the GCF and the standard GCF-to-LCM formula. The calculator runs entirely in your browser, so nothing you enter is uploaded anywhere, and there is no sign-in and no limit on how often you use it.

How to use the calculator, step by step

There is only one step: type two whole numbers. The results update live as you type.

  • Step 1 — Enter the first number. Type a whole number greater than 0 into the “First number” box. For example, type 12.
  • Step 2 — Enter the second number. Type a whole number greater than 0 into the “Second number” box. For example, type 18.
  • Step 3 — Read both answers. The calculator shows the GCF and the LCM in big type, then the prime factorization of each number underneath, and finally the check line: GCF × LCM equals the product of the two numbers. For 12 and 18 it shows GCF 6, LCM 36, 12 = 2² × 3, 18 = 2 × 3², and the check 6 × 36 = 216.
  • Step 4 — Start again. Change either number and the answers update instantly, or press Clear to empty both boxes and start over.

If you enter a zero, a decimal or a fraction, the calculator does not guess — it shows a friendly message explaining the problem (“Zero has no GCF or LCM” or “Whole numbers only, please”). Negative numbers are treated as their absolute value, so −12 and 12 give the same result. Very large numbers (above about 1,000,000,000) may be slow to factor, because prime factorization gets harder as numbers grow.

How the maths works

The GCF and the LCM are two sides of the same idea. The GCF (greatest common factor, also called the GCD or highest common factor) is the largest number that divides both of your numbers exactly, with no remainder. The LCM (least common multiple) is the smallest number that both of your numbers divide into exactly. For 12 and 18, the GCF is 6 and the LCM is 36.

The calculator finds the GCF with the Euclidean algorithm, which is the fastest way to do it by hand too. Divide the larger number by the smaller one and keep the remainder; then divide the smaller number by that remainder, and keep going until the remainder is 0. The last non-zero remainder is the GCF. For 12 and 18: 18 ÷ 12 leaves a remainder of 6, then 12 ÷ 6 leaves a remainder of 0, so the GCF is 6. For larger numbers the same steps just repeat a few more times.

Once the GCF is known, the LCM follows from one formula: LCM = (first number × second number) ÷ GCF. For 12 and 18 that is (12 × 18) ÷ 6 = 216 ÷ 6 = 36. This also gives a built-in check: GCF × LCM always equals the product of the two numbers (6 × 36 = 216 = 12 × 18). If your two numbers share no factor except 1, they are called coprime, and the LCM is simply their product — for 7 and 13, the GCF is 1 and the LCM is 7 × 13 = 91.

There is a second way to see the same answers, using prime factorization: break each number into primes. 12 = 2² × 3 and 18 = 2 × 3². The GCF takes the lowest power of each prime the two numbers share (2¹ × 3¹ = 6), and the LCM takes the highest power of each prime that appears in either number (2² × 3² = 36). The calculator shows both factorizations so you can follow this method as well.

Worked examples

Example 1 — 12 and 18. The factors of 12 are 1, 2, 3, 4, 6 and 12; the factors of 18 are 1, 2, 3, 6, 9 and 18. The largest factor they share is 6, so the GCF is 6. By the formula, the LCM is (12 × 18) ÷ 6 = 216 ÷ 6 = 36. Prime factors: 12 = 2² × 3 and 18 = 2 × 3². Check: 6 × 36 = 216 = 12 × 18.

Example 2 — 8 and 20. The factors of 8 are 1, 2, 4 and 8; the factors of 20 are 1, 2, 4, 5, 10 and 20. The largest shared factor is 4, so the GCF is 4. The LCM is (8 × 20) ÷ 4 = 160 ÷ 4 = 40. Prime factors: 8 = 2³ and 20 = 2² × 5. Check: 4 × 40 = 160 = 8 × 20. This is the classic case where the LCM (40) is smaller than the product (160) because the numbers share a factor.

Example 3 — 7 and 13 (coprime). 7 and 13 are both prime, so they share no factor except 1 — the GCF is 1. When the GCF is 1, the LCM is just the product: 7 × 13 = 91. Prime factors: 7 = 7 and 13 = 13. Check: 1 × 91 = 91 = 7 × 13. Two prime numbers are always coprime, and so are pairs like 8 and 15, which share no factor except 1 even though neither number is prime.

Example 4 — 15 and 25. The factors of 15 are 1, 3, 5 and 15; the factors of 25 are 1, 5 and 25. The largest shared factor is 5, so the GCF is 5. The LCM is (15 × 25) ÷ 5 = 375 ÷ 5 = 75. Prime factors: 15 = 3 × 5 and 25 = 5². Check: 5 × 75 = 375 = 15 × 25.

Example 5 — 60 and 90. The GCF of 60 and 90 is 30 (both divide by 30, and nothing larger divides both). The LCM is (60 × 90) ÷ 30 = 5,400 ÷ 30 = 180. Prime factors: 60 = 2² × 3 × 5 and 90 = 2 × 3² × 5. By the prime-factor method: the GCF takes the lowest powers (2¹ × 3¹ × 5¹ = 30) and the LCM takes the highest powers (2² × 3² × 5¹ = 180). Check: 30 × 180 = 5,400 = 60 × 90.

Common mistakes

  • Mixing up the GCF and the LCM. The GCF is always smaller than or equal to the smaller number (it divides both numbers), while the LCM is always larger than or equal to the larger number (both numbers divide into it). If your “GCF” is bigger than your numbers, or your “LCM” is smaller, the two answers are swapped — the GCF of 12 and 18 is 6, not 36.
  • Forgetting the number itself. Every number is a factor of itself and a multiple of itself. The GCF of 5 and 10 is 5 (the smaller number), and the LCM of 5 and 10 is 10 (the larger number), because 5 divides 10 exactly. The same applies whenever one number divides the other.
  • Using 0. Zero has no GCF or LCM in the usual sense — every number divides 0, so there is no greatest factor, and the only multiple 0 and another number share is 0 itself. The calculator rejects 0 with a clear message instead of giving a meaningless answer.
  • Thinking coprime means prime. Two numbers are coprime when their GCF is 1, but neither number has to be prime — 8 and 15 are coprime (GCF 1, LCM 120) even though both are composite. What matters is whether they share a factor, not whether they are prime.
  • Multiplying instead of dividing by the GCF. The LCM is the product divided by the GCF, not the product times the GCF. For 12 and 18, (12 × 18) ÷ 6 = 36 — multiplying would give 216 × 6 = 1,296, which is wrong. The check line (GCF × LCM = product) catches this error straight away.

Related tools

The LCM and GCF calculator sits in the Math group, and two companion tools cover other everyday number jobs.

  • Percentage Calculator — work out percentages, percentage increases and decreases, and what percentage one number is of another.
  • Word Counter — count the words and characters in a piece of text, handy when a homework answer or an essay has a word limit.

The Ratio Calculator and the Proportion Calculator are companion maths tools planned for ToolZana — check back for them. For all of ToolZana’s free tools, start at the ToolZana home page.

Tips for using the LCM and GCF

  • Adding fractions: the LCM of the denominators is the lowest common denominator. To add 1/12 + 1/18, use the LCM 36: 3/36 + 2/36 = 5/36.
  • Simplifying fractions: divide the top and bottom by the GCF. 18/24 simplifies by the GCF 6 to 3/4 — divide both by 6.
  • Timing things to line up: if one event repeats every 12 minutes and another every 18 minutes, they coincide every 36 minutes — the LCM of 12 and 18.
  • Cutting into equal pieces: to cut a 12-unit length and an 18-unit length into the longest equal pieces with nothing left over, cut each into 6-unit pieces — the GCF of 12 and 18.
  • Check your answer for free: GCF × LCM always equals the product of the two numbers. If 6 × 36 is not 216, one of the two answers is wrong.

The short version

The LCM and GCF Calculator finds both answers for any two whole numbers at once: the GCF, the largest number that divides both exactly, and the LCM, the smallest number both divide into exactly. For 12 and 18 the GCF is 6 and the LCM is 36; for 8 and 20 the GCF is 4 and the LCM is 40; for 7 and 13 the GCF is 1 and the LCM is 91; and for 15 and 25 the GCF is 5 and the LCM is 75. The GCF comes from the Euclidean algorithm and the LCM from the formula LCM = (first number × second number) ÷ GCF, and the calculator also shows the prime factorization of each number — 12 = 2² × 3 and 18 = 2 × 3². The built-in check is GCF × LCM = the product of the two numbers. The tool is free, runs entirely in your browser, and needs no sign-in.

Frequently Asked Questions

What is an LCM and GCF calculator?

An LCM and GCF calculator finds two answers for a pair of whole numbers at the same time: the GCF (greatest common factor), the largest number that divides both numbers exactly, and the LCM (least common multiple), the smallest number that both numbers divide into exactly. Enter two numbers — for example 12 and 18 — and it shows the GCF (6) and the LCM (36), plus the prime factorization of each number (12 = 2² × 3, 18 = 2 × 3²). This calculator is free, runs entirely in your browser, and needs no sign-in.

How do I use the LCM and GCF calculator?

Type two whole numbers greater than 0 into the two boxes — for example 12 and 18 — and the answers appear straight away: the GCF, the LCM, the prime factorization of each number, and a check line showing that GCF × LCM equals the product of the two numbers. The results update live as you type, so you can change either number and see the new answers instantly. Press Clear to empty both boxes and start over.

What is the GCF of 12 and 18?

The GCF of 12 and 18 is 6. The factors of 12 are 1, 2, 3, 4, 6 and 12, and the factors of 18 are 1, 2, 3, 6, 9 and 18 — the largest factor they share is 6. You can also see it from the prime factors: 12 = 2² × 3 and 18 = 2 × 3², so the GCF takes the lowest power of each shared prime, 2¹ × 3¹ = 6. The LCM of 12 and 18 is 36.

What is the LCM of 12 and 18?

The LCM of 12 and 18 is 36. The multiples of 12 are 12, 24, 36, 48 and so on, and the multiples of 18 are 18, 36, 54, 72 and so on — the smallest multiple they share is 36. You can also work it out from the GCF: LCM = (12 × 18) ÷ GCF = 216 ÷ 6 = 36. The GCF of 12 and 18 is 6, and the check is 6 × 36 = 216 = 12 × 18.

How do you find the GCF of two numbers?

The fastest way is the Euclidean algorithm: divide the larger number by the smaller one and keep the remainder, then divide the smaller number by that remainder, and keep going until the remainder is 0 — the last non-zero remainder is the GCF. For 12 and 18: 18 ÷ 12 leaves a remainder of 6, then 12 ÷ 6 leaves a remainder of 0, so the GCF is 6. The other way is to list the factors of each number and pick the largest one they share, or to use prime factorization and take the lowest power of each shared prime.

How do you find the LCM of two numbers?

First find the GCF, then use the formula LCM = (first number × second number) ÷ GCF. For 12 and 18, the GCF is 6, so the LCM is (12 × 18) ÷ 6 = 216 ÷ 6 = 36. The other way is prime factorization: the LCM takes the highest power of each prime that appears in either number — for 12 = 2² × 3 and 18 = 2 × 3², the LCM is 2² × 3² = 36. If the two numbers share no factor except 1, the LCM is simply their product.

What is the GCF and LCM of 8 and 20?

The GCF of 8 and 20 is 4, and the LCM of 8 and 20 is 40. The factors of 8 are 1, 2, 4 and 8, and the factors of 20 are 1, 2, 4, 5, 10 and 20, so the largest shared factor is 4. The LCM follows from the formula: (8 × 20) ÷ 4 = 160 ÷ 4 = 40. The prime factors are 8 = 2³ and 20 = 2² × 5, and the check is 4 × 40 = 160 = 8 × 20.

What does it mean if the GCF is 1?

If the GCF of two numbers is 1, the numbers are called coprime — they share no factor except 1. For example, 7 and 13 are coprime (GCF 1, LCM 91), and so are 8 and 15 (GCF 1, LCM 120), even though neither 8 nor 15 is prime. When the GCF is 1, the LCM is simply the product of the two numbers, because there is no shared factor to divide out. Two prime numbers are always coprime, but coprime pairs do not have to be prime.

What is the LCM and GCF used for in real life?

The LCM is used whenever two repeating things need to line up: if one event repeats every 12 minutes and another every 18 minutes, they coincide every 36 minutes (the LCM). It is also the lowest common denominator when adding fractions with different denominators — 1/12 + 1/18 becomes 3/36 + 2/36 = 5/36. The GCF is used for cutting things into the longest equal pieces with nothing left over, and for simplifying fractions: 18/24 simplifies by the GCF 6 to 3/4.

What are the prime factors of 12 and 18?

The prime factors of 12 are 2² × 3 (12 = 2 × 2 × 3), and the prime factors of 18 are 2 × 3² (18 = 2 × 3 × 3). These factorizations give the GCF and LCM directly: the GCF takes the lowest power of each shared prime, 2¹ × 3¹ = 6, and the LCM takes the highest power of each prime that appears, 2² × 3² = 36. The calculator shows the prime factorization of both numbers alongside every answer.

Why does the calculator not accept 0 or decimals?

Zero has no GCF or LCM in the usual sense: every number divides 0, so there is no greatest factor, and the only multiple 0 shares with another number is 0 itself — so the calculator rejects 0 with a clear message instead of giving a meaningless answer. Decimals and fractions are rejected for the same reason: factors and multiples are defined for whole numbers, so a number like 12.5 has no GCF or LCM. Negative numbers are accepted, because they are treated as their absolute value — −12 behaves exactly like 12.

Is the LCM and GCF calculator free?

Yes — the LCM and GCF Calculator is completely free, with no sign-in and no limits. It runs entirely in your browser, so nothing you enter is uploaded anywhere, and you can use it as often as you like, for any pair of whole numbers. Very large numbers above about 1,000,000,000 may be slow to factor, because prime factorization gets harder as numbers grow.