GCF & LCM Calculator
Find the greatest common factor and least common multiple of two whole numbers — with the full working shown.
Two results at once
Enter two integers and get both the greatest common factor (GCF) and the least common multiple (LCM) together.
Whole numbers only
The GCF and LCM are defined for integers. Decimals are rejected, and the GCF of zero and zero is undefined.
What are the GCF and LCM?
Greatest common factor and least common multiple
The greatest common factor (GCF, also called the greatest common divisor) is the largest whole number that divides two integers without a remainder. The least common multiple (LCM) is the smallest positive whole number that both integers divide into. Together they are the workhorses of fraction arithmetic: the GCF reduces a fraction to lowest terms, and the LCM gives the common denominator for adding fractions.
The fastest way to find the GCF is the Euclidean algorithm: repeatedly replace the larger number with the remainder of dividing it by the smaller, until the remainder is zero. The last non-zero value is the GCF. The LCM then follows directly from the GCF.
gcd(a, b) = gcd(b, a mod b), gcd(a, 0) = |a|; lcm = |a × b| ÷ gcfWorking on the absolute values means negative inputs behave just like their positive counterparts — the GCF and LCM are always reported as non-negative integers. Computing the LCM from the GCF (rather than listing multiples) keeps the arithmetic exact even for large numbers.
Suppose you want the GCF and LCM of 12 and 18.
Divide and take the remainder
18 ÷ 12 leaves a remainder of 6, so gcd(18, 12) = gcd(12, 6).Repeat until the remainder is zero
12 ÷ 6 leaves a remainder of 0, so the GCF is 6.Find the LCM from the GCF
12 × 18 ÷ 6 = 216 ÷ 6 = 36, the least common multiple.
A GCF of 1 means the two numbers are coprime — they share no factor other than 1, so a fraction made from them is already in lowest terms. A larger GCF is the factor you divide out to simplify. The LCM is the common denominator you would use to add fractions with these denominators, and the point at which two repeating cycles line up again. When one of the numbers is zero, the LCM is zero, because zero is the only multiple they share.
The arithmetic is exact, but the definitions have edges worth keeping in mind.
Integers only, and zero is a special case
The GCF and LCM are defined for whole numbers, so decimals are rejected. The GCF of any number and zero is that number's magnitude, but the GCF of zero and zero is undefined — there is no largest common divisor — so the calculator returns no result for that case. When either input is zero, the LCM is reported as zero.