LCM & GCD Calculator

Lowest common multiple and greatest common divisor.

Show details

Enter two or more whole numbers to find both their greatest common divisor (GCD, also called the HCF) and their lowest common multiple (LCM). The GCD is the biggest number that divides them all; the LCM is the smallest number they all divide into.

Loading calculator...

LCM and GCD — The Quick Answer

The GCD (greatest common divisor, or HCF) is the largest number that divides every value exactly. The LCM (lowest common multiple) is the smallest number every value divides into. They're linked: for two numbers, GCD × LCM = the product of the numbers.

Shortcut

GCD × LCM = a × b → LCM(a, b) = (a × b) ÷ GCD(a, b)

Worked examples

NumbersGCD (HCF)LCM
12, 18636
8, 12, 204120
7, 13191
6, 9318

When the GCD is 1 the numbers are 'coprime' — they share no common factor, so their LCM is simply their product (7 and 13 → LCM 91).

How It Works

1
Enter two or more positive whole numbers, separated by commas or spaces
2
The calculator finds the GCD using the Euclidean algorithm — repeatedly replacing the larger number with its remainder when divided by the smaller
3
For more than two numbers, it folds the result across the list, taking the GCD of the running result and the next number
4
It computes the LCM from the GCD using LCM = (a × b) ÷ GCD, again folding across the whole list
5
Both results appear instantly

The Method

Euclidean algorithm and the GCD–LCM relationship

Formula

GCD(a, b): repeat b, a mod b until the remainder is 0 LCM(a, b) = (a × b) ÷ GCD(a, b) For a list: fold GCD and LCM across all numbers

Variables

GCD / HCF

Greatest common divisor

The largest whole number that divides every value with no remainder. 'HCF' (highest common factor) is the same thing under a different name. Found fast with the Euclidean algorithm, no factoring needed.

LCM

Lowest common multiple

The smallest positive number that every value divides into exactly. Most often needed to find a common denominator when adding fractions, or to work out when repeating events line up again.

× relationship

How they connect

For two numbers, GCD × LCM always equals their product. That's why the LCM can be found by dividing the product by the GCD rather than listing multiples.

Note: For three or more numbers the same identity is applied step by step: take the GCD (or LCM) of the first two, then combine that with the third, and so on.

Worked Example

GCD and LCM of 12 and 18

1

GCD by the Euclidean algorithm

18 mod 12 = 6, then 12 mod 6 = 0. The last non-zero remainder is 6, so GCD(12, 18) = 6.

2

LCM from the GCD

LCM = (12 × 18) ÷ 6 = 216 ÷ 6 = 36.

3

Check

36 ÷ 12 = 3 and 36 ÷ 18 = 2 — both whole, so 36 is a common multiple, and it's the smallest one.

Reference Guide

unitvaluenote
12, 18GCD 6 · LCM 36share a factor of 6
8, 12, 20GCD 4 · LCM 120three numbers
7, 13GCD 1 · LCM 91coprime

Key Features

GCD (HCF) and LCM together, from the same input
Works with two numbers or a long list
Uses the fast Euclidean algorithm — exact, no factoring required
Flags when a result grows too large for exact precision
Copy the result in one tap
Runs entirely in your browser — nothing you enter is sent anywhere

Last updated: October 5, 2026

Tufail Ahmed

Creators

Tufail Ahmed

Computer Scientist & Developer Tools Author

Reviewers

Khizar Nadim

Technical Reviewer

Quick Facts

CategoryMath & Statistics
Cost Free
Last updated2026-10-05

Privacy Guaranteed

Your data never leaves your browser. All calculations are 100% private.

Frequently Asked Questions

What is the difference between GCD, HCF, and GCF?

They are three names for exactly the same thing: the greatest common divisor (GCD), highest common factor (HCF), and greatest common factor (GCF) all mean the largest whole number that divides every value in your set with no remainder.

How do you find the LCM of two numbers?

The quickest way is to divide the product of the two numbers by their GCD: LCM = (a × b) ÷ GCD. For 12 and 18, that's (12 × 18) ÷ 6 = 36. This is faster and less error-prone than listing out multiples until you find a match.

What does it mean if the GCD is 1?

The numbers are 'coprime' (relatively prime) — they share no common factor other than 1. In that case their LCM is simply their product. For example 7 and 13 are coprime, so their LCM is 7 × 13 = 91.

When do I actually need the LCM or GCD?

The LCM is used to find a common denominator when adding or subtracting fractions, and to work out when repeating cycles coincide (e.g. two buses leaving every 12 and 18 minutes next depart together after 36 minutes). The GCD is used to simplify fractions and ratios to lowest terms.