LCM and GCF Calculator
The GCF is the largest number that divides all your values; the LCM is the smallest number they all divide into. Enter two or more whole numbers to get both at once.
Your numbers
Result
- Count
- 2
| Item | Value |
|---|---|
| Numbers | 12, 18 |
| GCF (greatest common factor) | 6 |
| LCM (least common multiple) | 36 |
What the GCF and the LCM actually are
The greatest common factor — GCF, also written GCD for greatest common divisor — is the largest number that divides all your values with nothing left over. For 12 and 18 it is 6. The least common multiple is the opposite end: the smallest number that all your values divide into. For 12 and 18 it is 36. The two are bounded in opposite directions, which is a useful sanity check. The GCF can never exceed the smallest number in the list, and the LCM can never be smaller than the largest. If a result violates either, something went wrong in the input. Both are defined for positive whole numbers. This calculator rounds what you type, takes absolute values and discards zeros, because "the largest number dividing 0" and "the smallest multiple of 0" are not questions with useful answers.
Two ways to find them
The method taught first is prime factorization. Break each number down: 12 = 2² × 3 and 18 = 2 × 3². For the GCF take the *lowest* power of each shared prime — 2¹ × 3¹ = 6. For the LCM take the *highest* power of every prime that appears anywhere — 2² × 3² = 36. It is a clear way to see why the answers come out where they do.
It is also hopeless on large numbers, because factoring is hard. What software actually runs is the Euclidean algorithm, described in Euclid's Elements and still the standard method: replace the pair (a, b) with (b, a mod b) and repeat until the remainder is zero. The last non-zero value is the GCF.
For 18 and 12: 18 mod 12 = 6, then 12 mod 6 = 0, so the GCF is 6. Two steps, no factoring. The step count grows only with the *number of digits*, which is why it stays fast on values with hundreds of them. The slowest possible inputs are consecutive Fibonacci numbers.
The LCM is then derived rather than searched for: LCM = a ÷ GCF × b. Dividing before multiplying keeps intermediate values small.
The identity that links them — and its limit
For exactly two numbers, GCF × LCM = a × b. With 12 and 18: 6 × 36 = 216 = 12 × 18. That identity is the reason the LCM never has to be searched for once the GCF is known.
It does not generalize to three or more values, and this is the single most common mistake with these two quantities. Take 2, 3 and 4: the GCF is 1 and the LCM is 12, so 1 × 12 = 12, while the product of the numbers is 24. The extra factor of 2 is shared between 2 and 4 and gets counted twice on one side and once on the other.
For longer lists both quantities are still well defined — you just build them up pairwise, which is what this page does: fold the GCF across the list, then fold the LCM across the list. The order does not matter, because both operations are associative.
Where they get used
The GCF is what reduces a fraction to lowest terms. To simplify 18/24, divide both parts by their GCF of 6 and get 3/4 in one move instead of several. It also answers the physical version of the same question: the largest square tile that fits a 12 ft by 18 ft floor with no cutting is 6 ft on a side, and you would need 6 of them.
The LCM finds a common denominator. Adding 1/12 + 1/18 means rewriting both over 36. It also predicts when repeating cycles line up: buses leaving every 12 and every 18 minutes depart together every 36 minutes, and two gears with 12 and 18 teeth return to their starting alignment after 36 tooth-steps.
The most-cited example in nature is the periodical cicada, which emerges on 13-year and 17-year cycles. Both are prime, so the two broods share a multiple only every 221 years — a long gap that is a direct consequence of the numbers being coprime.
Edge cases worth knowing
Two numbers with no common factor beyond 1 are called *coprime* or *relatively prime*. Their GCF is 1 and, because of the identity above, their LCM is simply their product: 8 and 15 give a GCF of 1 and an LCM of 120. Coprimality is not the same as being prime — neither 8 nor 15 is prime. If one number divides the other, the answers collapse: for 6 and 24 the GCF is 6 and the LCM is 24. Nothing new is generated. The number 1 is a factor of everything, so a list containing 1 always has a GCF of 1. It changes the LCM not at all. With negative inputs the sign is conventionally dropped: divisors come in ± pairs, so "greatest" is taken over the positive ones. This calculator applies that convention automatically.
Frequently asked questions
Sources
Embed this calculator
Copy the code and paste it into your site or blog. Credit with a link back to Contania is included, and the height adjusts itself.
<iframe src="https://contania.app/embed/math/lcm-gcd" title="LCM and GCF Calculator" width="100%" height="720" loading="lazy" style="border:1px solid #e5e0d8;border-radius:12px;max-width:640px"></iframe>
<script>window.addEventListener("message",function(e){if(e.data&&e.data.type==="contania:embed-height"){var f=document.querySelector('iframe[src="https://contania.app/embed/math/lcm-gcd"]');if(f){f.style.height=e.data.height+"px"}}});</script>Related calculators
Prime Number
Check whether a number is prime, see its prime factorization if it is not, and find the next prime number.
CalculateFractions
Add, subtract, multiply and divide fractions, with the result already simplified and shown as a decimal. Enter the numerators and denominators.
CalculateFactorial
Calculate the factorial of a number (n!) — the product of all whole numbers from 1 to n. Exact results for large values using big-integer math.
CalculateLinear Equation
Solve a linear equation of the form ax + b = cx + d for x, with the step-by-step work. Handles no-solution and infinite-solution cases.
Calculate