UnitConv

GCF & LCM Calculator

Find the greatest common factor and least common multiple with prime factorisation

inputHint

gcdLabel
6
gcdSub
lcmLabel
36
lcmSub

factorTitle

12=2² × 3
18=2 × 3²

factorDesc

euclidTitle

  1. 1
    GCD(12, 18) = 6

euclidDesc

formulaTitle

GCD(a, b): a = q·b + r ⟹ GCD(a, b) = GCD(b, r)
LCM(a, b) = (a × b) ÷ GCD(a, b)

formulaDesc

What are GCF and LCM?

The greatest common factor (GCF, also called the greatest common divisor or GCD) is the largest whole number that divides two or more numbers exactly. The least common multiple (LCM) is the smallest positive number that every one of them divides into. These two ideas power a huge amount of school maths: reducing fractions uses the GCF, while adding or subtracting fractions needs the LCM as a common denominator. They also appear in scheduling problems — when two repeating events line up again — and in tiling, packaging and gear design. This calculator finds both for a whole list of numbers and shows the prime factorisation so you can see exactly where the answer comes from.

How to use it

Type two or more whole numbers separated by commas or spaces, for example 12, 18, 24. The calculator instantly shows the GCF and the LCM. Below that it lists the prime factorisation of each number and the running Euclidean-algorithm steps used to reach the GCF, so you can follow or check the work. If any number is 0 the LCM is undefined and is shown as a dash, while the GCF still uses the non-zero values.

The methods

The Euclidean algorithm finds the GCF: divide the larger number by the smaller, keep the remainder, then repeat with the smaller number and that remainder until the remainder is 0 — the last non-zero value is the GCF. The LCM of two numbers follows from LCM(a, b) = a × b ÷ GCF(a, b). For more than two numbers both are applied pairwise across the list. The prime-factor view computes the GCF as the product of the shared prime powers and the LCM as the product of the highest prime powers.

Reading the result

A GCF of 1 means the numbers are coprime — they share no common factor other than 1. A large GCF means the numbers have a lot in common and a fraction built from them can be reduced a long way. The LCM is always at least as large as the biggest input and is the first point at which all the numbers' cycles coincide, which is why it works as a common denominator. The prime factorisation makes both clear: shared primes build the GCF, all primes at their highest power build the LCM.

Frequently asked questions

What is the difference between GCF and LCM?

The GCF is the largest number that divides them all; the LCM is the smallest number they all divide into.

How does the Euclidean algorithm work?

Divide the larger by the smaller and keep the remainder, then repeat with the smaller number and the remainder until it reaches 0. The last non-zero value is the GCF.

How are GCF and LCM related?

For two numbers, GCF × LCM equals the product of the numbers, so LCM = a × b ÷ GCF.

Why is the LCM useful for fractions?

The LCM of the denominators is the least common denominator, which lets you add or subtract fractions with the smallest possible numbers.