Audited 05 Aug 2026·Last updated 28 Oct 2026·3 citations·Tier 2·0 uses

Least Common Factor Calculator

Find the smallest prime two whole numbers share, along with their greatest common factor, via Euclid's algorithm. Shows 1 when the pair is coprime.

Least Common Factor Calculator

Least common prime factor
2
The smallest prime that divides both numbers exactly; it reads 1 when the numbers share no prime factor at all.
Greatest common factor
42

Background.

Ask for the least common factor of two whole numbers and the literal answer is always 1, because 1 divides everything. That is rarely what anyone means. The useful question is the smallest factor bigger than 1 that the two numbers share, and that number is always prime: if it were composite, one of its own prime factors would be a smaller shared factor. So the question is answered here as the least common prime factor.

The tidy way to find it goes through the greatest common factor. Every number that divides both a and b also divides their GCF, so the primes the two numbers share are exactly the primes inside the GCF. Find the GCF with Euclid's algorithm, which keeps replacing the larger number by the remainder left after dividing by the smaller, then look for the GCF's smallest prime divisor. For 84 and 126 the GCF is 42, and the smallest prime in 42 is 2.

The result is handy when you simplify a fraction by hand one step at a time, or work down a factor ladder to build the GCF and the least common multiple. It also settles a yes-or-no question quickly. If the GCF is 1, the numbers share no prime at all and are called coprime, and the page then shows 1 in both result fields; read that as no common prime factor, since 1 is not itself a prime.

Both inputs must be positive whole numbers, up to 9 × 10¹⁵. If what you need is the smallest number that both values divide into, that is the least common multiple, a different quantity: for 84 and 126 it is 252.

What is least common factor calculator?

The least common prime factor of two positive integers is the smallest prime that divides both of them exactly. It equals their smallest common factor greater than 1, and it is always the smallest prime factor of their greatest common factor. Two numbers with no common prime factor, such as 8 and 15, are coprime, and their greatest common factor is 1. The GCF is shown as well because it holds every factor the pair have in common.

How to use this calculator.

  1. Enter two positive whole numbers; the order does not matter. Decimals, zero and negative numbers are refused.
  2. Read the least common prime factor. A result of 2 simply means both numbers are even; anything larger tells you the pair share an odd prime.
  3. Read the greatest common factor beside it. Dividing both numbers by the GCF reduces a fraction to lowest terms in one step.
  4. If both results are 1, the numbers are coprime: no prime divides both, and a fraction made from them is already in lowest terms.

The formula.

Find gcd(a,b), then its smallest prime divisor

The page computes g = gcd(a, b), then the smallest prime p that divides g. The GCF comes from Euclid's algorithm: replace the pair (a, b) with (b, a mod b) until the remainder is zero, and the last non-zero value is the GCF. For 84 and 126 that takes two steps, 126 mod 84 = 42 and 84 mod 42 = 0. Next it tries divisors 2, 3, 4, 5 and upward, stopping at the first one that divides g. Trying composite candidates does no harm, because a composite divisor would have been beaten by one of its own prime factors earlier in the list. Only candidates up to √g need testing; if none divides g, then g is itself prime and is the answer. When g is 1 there is nothing to test and the result stays at 1. Because the common prime factors of a and b are exactly the prime factors of g, the method cannot miss a smaller shared prime.

A worked example.

Example

Take 84 and 126. Euclid's algorithm divides 126 by 84, leaving a remainder of 42, then divides 84 by 42, leaving 0, so the greatest common factor is 42. Testing 42 for its smallest prime divisor stops at the first candidate, since 42 ÷ 2 = 21 exactly. The least common prime factor is 2. Prime factorisation agrees: 84 = 2² × 3 × 7 and 126 = 2 × 3² × 7 share 2, 3 and 7, of which 2 is the smallest. The pair's common factors are the eight divisors of 42: 1, 2, 3, 6, 7, 14, 21 and 42. A less obvious pair, 91 and 143, are both odd and divisible by neither 3 nor 5, yet they share 13, which is also their GCF.

integer A84
integer B126

Frequently asked questions.

Isn't the least common factor of any two numbers just 1?
Strictly, yes, which is why the phrase is almost always meant as the smallest shared factor above 1. That number is necessarily prime, because any composite shared factor would contain a smaller prime that is also shared. The page therefore reports the least common prime factor, and shows 1 only when no prime is shared.
Was I really looking for the least common multiple?
Possibly. The least common multiple is the smallest number both values divide into, and it is what you need for a common denominator. It equals a × b ÷ GCF, so for 84 and 126 it is 84 × 126 ÷ 42 = 252. The least common prime factor goes the other way, into the numbers rather than above them.
What does a result of 1 tell me?
That the two numbers are coprime: their greatest common factor is 1, so no prime divides both. Neither number has to be prime for this to happen; 8 and 15 are both composite but share nothing. A fraction such as 8/15 is therefore already in its lowest terms.
How can I spot the shared prime without a calculator?
Check 2 first (both even), then 3 (both digit sums divisible by 3), then 5 (both ending in 0 or 5). Beyond that, subtracting helps, because any shared factor also divides the difference. For 91 and 143 the difference is 52 = 4 × 13, which points straight at 13.
How does the smallest shared prime help me simplify a fraction?
Divide top and bottom by it and repeat on what is left. For 84/126, dividing by 2 gives 42/63, by 3 gives 14/21, and by 7 gives 2/3, which cannot be reduced further. Dividing by the GCF of 42 reaches 2/3 in a single step.
Can I find the smallest prime shared by three numbers?
Yes, in two passes. The GCF of three numbers is the GCF of the first pair's GCF and the third number. For 84, 126 and 105, enter 42 and 105: their GCF is 21, and the least common prime factor of all three is 3, since 105 is odd.

How this page was produced

Published by
Quanta Calculator
Primary sources
3 cited below
Method
Find gcd(a,b), then its smallest prime divisor
Published
Last verified

Built with AI assistance and verified by automated tests against the cited sources — every worked example on this page is computed by the same code that runs the calculator. How we build and check calculators.

In this category

Embed

Quanta Pro

Paid features are coming later.

  • All 1560 calculators remain free
  • No billing is enabled
Coming soon