About this tool
Greatest common divisor and least common multiple of two numbers.
The LCM and GCD Calculator finds the greatest common divisor (GCD, also called HCF) and the least common multiple (LCM) of two whole numbers. It uses the Euclidean algorithm — repeatedly replacing the pair with the smaller number and the remainder until the remainder is zero — and then derives the LCM from the identity LCM(a, b) = a x b / GCD(a, b), computed as (a / g) x b so the intermediate product stays small. Enter 12 and 18 and it returns GCD 6 and LCM 36.
Open LCM and GCD Calculator on AltFTool — it loads instantly in your browser.
Type a value into the 'First number' box under Inputs, which opens at 12. Decimals are floored and negatives are made positive, so 12.9 and -12 are both treated as 12.
Fill in the 'Second number' box, which opens at 18. Enter 0 in either box and the Result stays an em dash with the caption 'Enter two whole numbers'.
There is no calculate button — the Result recomputes as you type, reading 'GCD 6 · LCM 36' for the default 12 and 18, with cards labelled 'GCD (HCF)' and 'LCM' beneath it. Copy sends that text to the clipboard, Download saves it as lcm-and-gcd-calculator.txt, and Reset returns the boxes to 12 and 18.
GCD and LCM are returned together, which is what you usually need, since one is derived from the other.
The remainder method converges in a handful of steps even for large inputs, instead of testing every candidate factor.
Values are taken as whole numbers and signs ignored, so a negative or decimal entry still returns the divisor and multiple of the magnitudes.
The GCD is the largest number that divides both values exactly; the LCM is the smallest number both values divide into exactly. For 12 and 18 the GCD is 6 and the LCM is 36 — the GCD is never larger than the smaller input, and the LCM is never smaller than the larger one.
Yes. Highest common factor (HCF), greatest common divisor (GCD) and greatest common factor (GCF) all name the same quantity; HCF is the usual term in Indian and British syllabuses and GCD the usual term elsewhere.
Multiply the two numbers and divide by their GCD: LCM(a, b) = a x b / GCD(a, b). For 12 and 18 that is 216 / 6 = 36. This identity holds for any pair of positive integers, which is why one calculation gives both results.
It is 1, and the numbers are called coprime or relatively prime — 8 and 15, for example. In that case the LCM is simply the product of the two numbers, 120.
Add the LCM and GCD Calculator widget to your blog or website — free, responsive, no signup. Just keep the “Widget by AltFTool” credit link visible.
<iframe src="https://www.altftool.com/embed/widget/lcm-and-gcd-calculator"
title="LCM and GCD Calculator — free AltFTool widget"
width="100%" height="640" style="border:0;border-radius:12px;overflow:hidden"
loading="lazy" referrerpolicy="no-referrer-when-downgrade" allow="clipboard-write"></iframe>
<p style="font-size:12px;margin:4px 0 0">Widget by <a href="https://www.altftool.com/tools/all/lcm-and-gcd-calculator?utm_source=embed&utm_medium=widget" rel="nofollow">AltFTool — free online tools</a></p>