GCD Calculator

The greatest common divisor (GCD), called HCF in Indian schools, is the largest number that divides all the given numbers exactly. It is used to simplify fractions and ratios.

Two or more whole numbers, separated by commas or spaces.
Results update as you type.

GCD (HCF)

42

LCM of the same numbers
1,260

About this calculator

Enter two or more whole numbers.

How to use it

  1. Enter the numbers, separated by commas.
  2. Read the GCD and LCM.

The formula

GCD(a, b) = GCD(b, a mod b), until the remainder is 0
mod
remainder after division

Worked example

84, 126 and 210

  1. GCD(84, 126) = 42; GCD(42, 210) = 42.
  2. So the HCF is 42; the LCM is 1,260.

What the result means

For two numbers, GCD × LCM = the product of the numbers.

Euclid’s division algorithm, step by step

This is the method the calculator uses. Divide the larger number by the smaller, then divide the divisor by the remainder, and repeat until the remainder is 0. The last non-zero remainder is the HCF. For 867 and 255:

  • 867 = 255 × 3 + 102
  • 255 = 102 × 2 + 51
  • 102 = 51 × 2 + 0
  • The remainder is now 0, so HCF(867, 255) = 51.

Prime factorisation method

Write each number as a product of primes, then multiply the lowest power of every prime that appears in all of them. Using the page example:

  • 84 = 2² × 3 × 7
  • 126 = 2 × 3² × 7
  • 210 = 2 × 3 × 5 × 7
  • Common primes at their lowest powers: 2 × 3 × 7 = 42, the HCF.
  • Every prime at its highest power gives the LCM: 2² × 3² × 5 × 7 = 1,260.

HCF and LCM of common pairs

HCF × LCM = product of the numbers holds for two numbers only: 36 × 48 = 1,728 = 12 × 144. For 4, 6 and 8 the HCF is 2 and the LCM is 24, giving 48, but the product is 192.

HCF and LCM of pairs often seen in exercises
NumbersHCFLCM
12, 18636
16, 24848
18, 27954
24, 361272
36, 4812144
15, 25575
30, 451590
48, 7224144
56, 8428168
60, 9030180
8, 151120

Assumptions

  • Whole numbers.

Limitations

  • Very large numbers above 10¹⁵ are not accepted.

Frequently asked questions

Is GCD the same as HCF?

Yes, and also GCF.

What is the HCF of 12 and 18?

6.

How is GCD used?

To simplify fractions and ratios.

What is the HCF of 36 and 48?

12. Their LCM is 144.

What is the HCF of two consecutive numbers?

Always 1. Any number dividing both would also divide their difference, which is 1, so HCF(14, 15) = 1.

Last reviewed on 12 October 2026. How we calculate and check. Found a mistake? Tell us.