Gcf And Lcm Calculator

Free GCF and LCM calculator that finds the greatest common factor and least common multiple of two or more integers at once, using the Euclidean algorithm and the identity lcm(a, b) = |a × b| ÷ gcf(a, b).

GCF and LCM calculator

Find the greatest common factor and least common multiple of two or more integers.

Results for 3 numbers

Greatest common factor

6

Least common multiple

180

Calculated from: 12, 18, 30

GCF and LCM calculator guide

The greatest common factor (GCF), also called the greatest common divisor (GCD) or highest common factor (HCF), is the largest positive integer that divides each of the given numbers without a remainder. The least common multiple (LCM) is the smallest positive integer that is a multiple of every given number. The two are complementary: the GCF captures what the numbers share as divisors, while the LCM captures the first point where their multiples coincide.

Enter two or more integers separated by commas or spaces and select Calculate. The calculator folds the pairwise operations across the whole list — gcf(a, b, c) = gcf(gcf(a, b), c) and likewise for the LCM — so it handles any reasonable number of values, not just pairs. Negative inputs are treated by their absolute value, because common factors and multiples are defined by divisibility, not sign.

How to use this GCF and LCM calculator

  1. Enter the integers: Type two or more whole numbers into the box, separated by commas or spaces, for example 12, 18, 30. Negative integers are allowed and are treated by their absolute value.
  2. Select Calculate: Press Calculate to evaluate the list. Empty input, non-integer tokens such as 12.5 or abc, and lists with fewer than two numbers produce a descriptive error instead of a result.
  3. Read the GCF and LCM: The left card shows the greatest common factor and the right card shows the least common multiple of the entire list. The parsed integers are repeated below so you can confirm what was entered.
  4. Reset or share: Use Reset to return to the example list, or copy the link to share the current set of numbers — the inputs are encoded in the page URL.

Formula and variables

The GCF is computed with the Euclidean algorithm: repeatedly replace the larger number by the remainder of the division until the remainder is zero; the last non-zero remainder is the greatest common divisor. The LCM follows from the GCF through the identity lcm(a, b) = |a × b| ÷ gcf(a, b), which holds for any two integers. For three or more numbers, each operation is applied pairwise across the list, which is valid because both the GCF and the LCM are associative.

gcf(a, b) = gcf(b, a mod b) until the remainder is 0;  lcm(a, b) = |a × b| ÷ gcf(a, b)
a, bInput integers
Two whole numbers from the entered list; signs are ignored. (unitless integer)
a mod bRemainder
The remainder when a is divided by b, used in each Euclidean step. (unitless integer)
gcf(a, b)Greatest common factor
The largest positive integer dividing both a and b exactly. (unitless integer)
lcm(a, b)Least common multiple
The smallest positive integer that is a multiple of both a and b. (unitless integer)

Worked example: GCF and LCM of 12, 18, and 30

Find the greatest common factor and least common multiple of the default example list 12, 18, 30 using prime factorization, which matches the calculator result.

Integers
12, 18, 30
  1. Write the prime factorizations: 12 = 2² × 3, 18 = 2 × 3², 30 = 2 × 3 × 5.
  2. GCF: take each prime that appears in every factorization with its smallest exponent: 2¹ × 3¹ = 6.
  3. LCM: take every prime that appears in any factorization with its largest exponent: 2² × 3² × 5 = 180.
  4. Pairwise check for the GCF with the Euclidean algorithm: gcf(12, 18) = gcf(18, 12) = gcf(12, 6) = 6, then gcf(6, 30) = 6.
  5. Pairwise check for the LCM: lcm(12, 18) = (12 × 18) ÷ 6 = 36, then lcm(36, 30) = (36 × 30) ÷ gcf(36, 30) = 1080 ÷ 6 = 180.

Result: GCF = 6 and LCM = 180

Six is the largest number that divides 12, 18, and 30 evenly, so all three quantities can be split into equal groups of 6 (or into 6 equal groups). One hundred eighty is the smallest number that all three divide into evenly — for example, events repeating every 12, 18, and 30 days first coincide on day 180.

Understanding your results

Greatest common factor (GCF)

The GCF is the largest integer that divides every entered number without a remainder. A GCF of 1 means the numbers are relatively prime: they share no common factor other than 1, so a fraction built from any two of them is already in lowest terms.

Least common multiple (LCM)

The LCM is the smallest positive integer divisible by every entered number. If any input is 0, the LCM is reported as 0 by convention, because 0 is the only number divisible by 0. The LCM grows quickly, so lists of large or mutually prime numbers can produce very large results.

How the two results relate

For exactly two numbers, gcf(a, b) × lcm(a, b) = |a × b| — for example, gcf(12, 18) × lcm(12, 18) = 6 × 36 = 216 = 12 × 18. This identity does not extend to three or more numbers: for 12, 18, 30 the product 6 × 180 = 1,080 is not equal to 12 × 18 × 30 = 6,480.

Assumptions

  • All inputs are whole numbers (integers); decimals and fractions are rejected.
  • Results are non-negative: negative inputs are treated by their absolute value, since divisibility does not depend on sign.
  • A list containing 0 has an LCM of 0 by convention; gcf(0, 0) = 0.
  • Every input and intermediate result must fit within exact integer range (about 9 × 10¹⁵); larger values are rejected rather than approximated.

Limitations

  • The calculator reports only the final GCF and LCM, not step-by-step Euclidean divisions or prime factorizations.
  • The product identity gcf(a, b) × lcm(a, b) = a × b applies to pairs only, not to lists of three or more numbers.
  • Very large lists or values whose LCM exceeds exact integer range are rejected with an error instead of returning a rounded result.
  • Polynomial GCF/LCM and rational inputs are outside the scope of this calculator.

Common mistakes

  • Confusing the two concepts: the GCF is never larger than the smallest input (ignoring zeros), while the LCM is never smaller than the largest input.
  • Including every prime factor in the GCF instead of only the primes common to all numbers; for 12 and 18 the GCF is 2 × 3 = 6, not 2² × 3².
  • Applying the identity gcf × lcm = product to three or more numbers, where it does not hold.
  • Entering decimals such as 2.5; the GCF and LCM are defined for integers, so the calculator rejects non-whole numbers.
  • Forgetting that a GCF of 1 is a valid answer meaning the numbers are relatively prime, not a sign of an error.
  • Assuming the LCM of two numbers is always their product; that is only true when their GCF is 1.

Practical use cases

Simplify fractions

Divide the numerator and denominator by their GCF to reduce a fraction to lowest terms in one step. For example, gcf(12, 30) = 6, so 12/30 simplifies directly to 2/5.

Add and subtract fractions

The LCM of the denominators is the least common denominator. For 1/4 + 1/6, lcm(4, 6) = 12, giving 3/12 + 2/12 = 5/12 with no further reduction needed.

Divide quantities into equal groups

The GCF gives the largest equal grouping: 12, 18, and 30 items can be split into 6 groups of 2, 3, and 5, which is the greatest uniform grouping possible.

Align repeating schedules

The LCM tells when cycles coincide: tasks repeating every 12, 18, and 30 days all fall on the same day every 180 days, because lcm(12, 18, 30) = 180.

Planning and decision guide

Use the GCF when splitting, the LCM when combining

If a problem asks for the largest equal pieces, rows, or groups, it is a GCF problem; if it asks when events next coincide or for a common denominator, it is an LCM problem. Identifying which quantity the question targets prevents the most common setup error.

Check a two-number answer with the product identity

For a pair of numbers, gcf(a, b) × lcm(a, b) must equal |a × b|. Multiply the two results and compare against the product of the inputs — a mismatch means one of the two values is wrong. Remember this check only works for exactly two numbers.

Reduce pairwise for very large lists

Because both operations are associative, you can compute the GCF or LCM of a long list by combining two numbers at a time in any order. If an intermediate LCM becomes too large to represent exactly, the calculator stops with an error rather than returning an inexact value.

Frequently asked questions

What is the difference between the GCF and the LCM?

The greatest common factor is the largest integer that divides every input exactly — it looks downward at shared divisors. The least common multiple is the smallest positive integer that every input divides into — it looks upward at shared multiples. For 12 and 18 the GCF is 6 and the LCM is 36.

What does a GCF of 1 mean?

It means the numbers are relatively prime (coprime): they share no common factor other than 1. In that case the LCM of a pair equals their product, and any fraction formed from the two numbers is already in lowest terms.

Does the identity GCF × LCM = product work for more than two numbers?

No. gcf(a, b) × lcm(a, b) = |a × b| holds only for pairs. For 12, 18, and 30 the product of the results is 6 × 180 = 1,080, while the product of the inputs is 6,480.

Can I enter negative numbers or zero?

Yes. Signs are ignored, because divisibility depends on absolute value, so gcf(−12, 18) = 6. A zero is allowed too: gcf(0, n) = |n|, and if any input is 0 the LCM is reported as 0 by convention.

Why does the calculator reject decimals like 2.5?

The GCF and LCM are defined for integers: a factor must divide evenly and a multiple must be a whole-number product. Decimals and non-numeric tokens are flagged with an error instead of being silently truncated.

How does the calculator find the GCF?

It uses the Euclidean algorithm: repeatedly replace the larger number by the remainder of dividing the two numbers until the remainder is 0; the last non-zero remainder is the GCF. The LCM is then computed as |a × b| ÷ gcf(a, b), and both operations are folded pairwise across the whole list.

How do I use the LCM to add fractions?

Take the LCM of the denominators as the common denominator, scale each numerator accordingly, then add. For 1/4 + 1/6, lcm(4, 6) = 12, so the sum is 3/12 + 2/12 = 5/12.

Sources and review

Reviewed 2026-08-19.

Continue with calculators that answer nearby questions and help compare the next step.