LCM and GCD Calculator
Type any list of whole numbers and this calculator returns their greatest common divisor and least common multiple side by side. It folds both results across the entire list, not just a pair, using Euclid's algorithm so the answer is exact even for large values. Negatives and zeros are accepted and handled by the usual mathematical conventions.
How to find the GCD and LCM
- Type your integers into the 'Integers' box, separating them with commas or spaces.
- Add as many numbers as you need; the tool updates as you type.
- Read the GCD (HCF) card for the largest value dividing every number.
- Read the LCM card for the smallest value that every number divides into.
- Click the copy icon on either card to grab that result.
Examples
GCD and LCM of 12, 18, 24
12, 18, 24
GCD 6, LCM 72
Coprime set 2, 3, 4
2 3 4
GCD 1, LCM 12
A single pair, 12 and 18
12, 18
GCD 6, LCM 36
Frequently asked questions
What is the difference between GCD and LCM?
The GCD is the largest integer that divides every number in your list without a remainder. The LCM is the smallest positive integer that each of your numbers divides into evenly. They answer opposite questions: the biggest shared factor versus the smallest shared multiple.
How is the GCD calculated?
It uses Euclid's algorithm. The calculator repeatedly replaces the larger number with the remainder of dividing it by the smaller one until the remainder hits zero, at which point the surviving value is the GCD. For three or more numbers it applies this pairwise across the list.
How is the LCM found from the GCD?
For any pair the least common multiple equals the absolute value of the product divided by the GCD, so lcm(a, b) = |a times b| / gcd(a, b). The calculator chains this across the whole list to get the overall LCM.
Can I enter more than two numbers?
Yes. Enter as many integers as you like separated by commas or spaces. The GCD and LCM are computed by folding the operation over every value, so a list of ten numbers works the same way as a single pair.
What happens if I include zero?
The GCD treats zero as a value it divides, so gcd(0, n) is the absolute value of n. Any LCM that involves a zero is defined as zero by convention, and the tool reports zero in that case.
Does it accept negative numbers?
Yes. Signs are ignored for both results because divisibility depends on magnitude, so the GCD and LCM are always reported as non-negative integers.
Why must the inputs be whole numbers?
GCD and LCM are only defined for integers. If you type a decimal or a value that is not a whole number, the tool flags it and asks for an integer instead of guessing.
Is HCF the same as GCD?
Yes. Highest common factor (HCF) and greatest common divisor (GCD) are two names for the same thing, which is why the result card is labelled GCD (HCF).
Is my input private?
Yes. The calculation runs entirely in your browser with JavaScript, and nothing you type is sent to a server.
Learn more
- GCD and LCM: how to find them by hand
Understand greatest common divisor and least common multiple, the prime-factor and Euclid methods, and where each one is actually useful.
Related tools
Factorial Calculator
Calculate the factorial of any non-negative integer with exact big-number precision. Get n! instantly, even for large values, then copy the result. Free.
Proportion Calculator
Solve a proportion a/b = c/d for the missing value. Leave one box blank and get the answer by cross multiplication, instantly and free. No signup needed.
Annulus Area Calculator
Calculate the area of an annulus, the ring between two concentric circles, from its outer and inner radius. Returns both circumferences and width too. Free.
Area Calculator
Find the area of a circle, square, rectangle, triangle, trapezoid, parallelogram, ellipse, sector or rhombus. Free and runs in your browser.
Arithmetic Sequence Calculator
Find the nth term, the sum of n terms and the full term list for any arithmetic or geometric sequence. Enter the first term, step or ratio, and n.
Average Calculator
Find the mean, median, mode, range, sum, count, min and max of a list of numbers. Paste values separated by commas, spaces or new lines.