GCD and LCM Calculator With HCF Steps

Enter two to eight non-negative whole numbers to find their greatest common divisor (GCD or HCF) and least common multiple (LCM). The calculator shows prime factors, Euclidean division steps and exact checks.

Written and checked by TheToolNet Editorial Team · Last reviewed: August 22, 2026 · How we check math tools

Two-number relationship
GCD(a,b) × LCM(a,b) = |a × b|

GCD and HCF are two names for the same value. For non-zero a and b, LCM(a,b) = |a × b| ÷ GCD(a,b).

AdvertisementReserved space — no ad is loaded

Calculate GCD, HCF and LCM

Separate 2–8 whole numbers with commas or spaces. Each value may be from 0 through 1,000,000,000,000.

Example: 24, 36, 60

Definitions used by this calculator

The highest common factor is the greatest positive whole number that divides every given number without a remainder. It is also called the greatest common divisor (GCD) or greatest common factor (GCF). The least common multiple is the smallest positive number divisible by every given non-zero number.

For 12 and 18, the HCF is 6 and the LCM is 36. Read what LCM and HCF mean in maths for a full comparison, methods and guidance on choosing the correct operation.

How to find HCF and LCM

Prime-factor method

Write each number as a product of primes. For HCF, take each common prime at its lowest exponent. For LCM, take every prime that appears at its highest exponent.

HCF by the long-division method

Divide the larger number by the smaller. Replace the pair with the previous divisor and remainder, then repeat. The last non-zero remainder is the HCF. This is the Euclidean algorithm used by the calculator.

LCM from the HCF

For two non-zero numbers, divide one number by the HCF before multiplying by the other. This avoids making the intermediate product unnecessarily large.

HCF and LCM of 2, 3 and 4

The prime factorizations are 2, 3 and 2². No prime divides all three, so HCF(2,3,4) = 1. Taking each prime at its largest exponent gives LCM = 2² × 3 = 12.

For 48 and 180, Euclid’s method gives 180 = 48 × 3 + 36, 48 = 36 × 1 + 12, and 36 = 12 × 3 + 0. Therefore the HCF is 12 and the LCM is 720.

AdvertisementReserved space — no ad is loaded

When to use LCM and when to use HCF

SituationUsually useReason
Cut lengths into the largest identical piecesHCFYou need the greatest size that divides every length.
Make the largest number of identical groupsHCFEach group must divide all quantities exactly.
Find when repeating schedules next coincideLCMYou need the first shared multiple of the cycle lengths.
Find a common denominator for fractionsLCMThe least common denominator is the LCM of denominators.

Words such as “largest” or “together” are clues, not rules. Decide whether the required answer must divide the quantities (HCF) or be divisible by them (LCM).

If the HCF of two numbers is 11 and their LCM is known

If two positive integers have HCF 11 and LCM L, their product is 11L. That information does not always identify one unique pair. Write the numbers as 11m and 11n, where m and n are coprime; then L = 11mn. Every coprime factor pair of L ÷ 11 gives a possible number pair.

For example, if HCF = 11 and LCM = 132, then mn = 12. Coprime factor pairs (1,12) and (3,4) produce the pairs (11,132) and (33,44). A question needs another condition if it expects only one pair.

Scope and zero cases

This calculator accepts non-negative integers, not decimals or fractions. It uses GCD(0,n) = n and LCM(0,n) = 0 when n is positive. It rejects the all-zero input because conventions for GCD(0,0) vary by context. Prime factorization is not defined for zero.

Frequently asked questions

Are GCD and HCF the same?

Yes. GCD, HCF and GCF are common names for the same largest positive integer that divides all inputs.

When should I use HCF rather than LCM?

Use HCF for the largest equal group or piece that divides each quantity. Use LCM for the first shared multiple, such as repeating schedules or common denominators.

Can the calculator use more than two numbers?

Yes. It accepts between two and eight non-negative whole numbers and applies the GCD and LCM operations pairwise.

What is the HCF and LCM of 2, 3 and 4?

The HCF is 1 and the LCM is 12.

Related tools and references

Start with our guide to LCM and HCF definitions, differences and uses. To practice the method on one number, use the prime factorization calculator with steps. Programmers can use the tested logic in our LCM and HCF in C guide.