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
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.
- Enter two positive whole numbers; the order does not matter. Decimals, zero and negative numbers are refused.
- 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.
- Read the greatest common factor beside it. Dividing both numbers by the GCF reduces a fraction to lowest terms in one step.
- 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.
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.
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.
Frequently asked questions.
Isn't the least common factor of any two numbers just 1?
Was I really looking for the least common multiple?
What does a result of 1 tell me?
How can I spot the shared prime without a calculator?
How does the smallest shared prime help me simplify a fraction?
Can I find the smallest prime shared by three numbers?
References& sources.
- [1]OpenStax, Rice University. College Algebra 2e, 2021. Algebra and function chapters. Retrieved 2026-08-06.
- [2]OpenStax, Rice University. Precalculus 2e, 2021. Trigonometry and analytic geometry chapters. Retrieved 2026-08-06.
- [3]NIST/SEMATECH. e-Handbook of Statistical Methods, 2012. Chapter 1.3 and Chapter 4. Retrieved 2026-08-06.
How this page was produced
- Published by
- Quanta Calculator
- Overseen by
- Daniel, Quanta Calculator Researcher
- 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