Two questions that are really one question

The greatest common divisor of two numbers is the largest number that divides both exactly. The lowest common multiple is the smallest number both divide into. They sound like opposites and they are tied together by one identity:

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

So you only ever need to compute one of them. Find the GCD, which is fast, then get the LCM by division. This is how every implementation does it, and it is why a calculator that finds the LCM by listing multiples is doing far more work than necessary.

Euclid algorithm — worked on 48 and 180

Euclid method is over two thousand years old and still the fastest general approach. Divide the larger by the smaller, keep the remainder, repeat with the pair you just used:

StepOperationRemainder
1180 ÷ 48 = 3 remainder 3636
248 ÷ 36 = 1 remainder 1212
336 ÷ 12 = 3 remainder 00 — stop

The last non-zero remainder is the answer: GCD(48, 180) = 12. Three steps, no factorising.

Now the LCM comes free: 48 × 180 ÷ 12 = 8,640 ÷ 12 = 720.

The prime factorisation view, which shows why it works

Break both numbers into primes:

For the GCD, take the lowest power of each shared prime: 2² × 3 = 12. For the LCM, take the highest power of every prime that appears in either: 2⁴ × 3² × 5 = 16 × 9 × 5 = 720. Same answers.

This method is more illuminating but much slower for large numbers, because factorising is hard while dividing is easy. Use it to understand the result; use Euclid to compute it.

Where these turn up in real work

Special cases worth knowing

Questions people actually ask

Is HCF the same as GCD?

Yes. Highest common factor, greatest common divisor and greatest common factor are three names for one thing. HCF is more common in British and South Asian curricula, GCD in computing and American texts.

How fast is Euclid algorithm really?

Remarkably fast. The number of steps grows with the logarithm of the inputs, and the worst case is a pair of consecutive Fibonacci numbers. Even for numbers with hundreds of digits it finishes in well under a thousand steps, which is why it underpins modular inverse computation in cryptography.

Can the GCD be larger than either number?

No. A divisor of a number cannot exceed it, so the GCD is at most the smaller input. Conversely the LCM is at least the larger input.

Are the numbers I enter stored?

No. Everything is computed in your browser, and nothing is transmitted or saved.

Keep exploring Gen Code Tools

Every tool comes with a written guide, and every category is one click away.