One Click Answers

OCACalculators

Share tool
FacebookPinterestEmail

GCD, LCM and Prime Factors Calculator

What is the GCD and LCM of two numbers?

Find the greatest common divisor and least common multiple of your numbers, or break one number into its factors.

About this tool & how to use it

What it does

Find the GCD and LCM of two or more numbers, check whether a number is prime, list its prime factors and all its factors, or simplify a square root.

How to use it

  1. Choose what to work out: the GCD and LCM, a prime check with prime factors, all the factors of a number, or a square root.
  2. Enter the number or numbers. For the GCD and LCM, separate two to twelve whole numbers with commas.
  3. Read the answer in the sentence at the top, then the steps or the full list below it.

One click answer

Your answer will appear here.

Fill in the form and your answer appears here as you type.

Related tools

Try another answer

How we calculated this

The GCD (greatest common divisor, also called the greatest common factor) is the largest number that divides every number in the list. It is found with Euclid's method: divide, keep the remainder, and repeat until the remainder is 0.

The LCM (least common multiple) is the smallest number that every number in the list divides. For two numbers it is their product divided by their GCD: 12 × 18 ÷ 6 = 36.

A prime number has exactly two factors, 1 and itself. Prime factorization splits a number into primes, for example 84 = 2² × 3 × 7, and all its factors can be built from those primes.

A square root is simplified by pulling out every pair of equal prime factors: 72 = 2 × 2 × 2 × 3 × 3, so √72 = 2 × 3 × √2 = 6√2.

Formulas and details
  • GCD(a, b): repeat (a, b) → (b, a mod b) until b is 0
  • LCM(a, b) = a × b ÷ GCD(a, b)
  • √n = outside × √inside, taking out every pair of equal prime factors

Assumptions

  • The GCD and LCM need whole numbers greater than 0. Factoring and the prime check work up to 1,000,000,000,000.
  • The GCD and LCM are exact whole numbers, however large. Decimal square roots are shown to at most 6 decimal places.
  • Everything you enter is worked out in your browser and is never sent anywhere.

Example

Input: GCD and LCM of 12 and 18

Result: The GCD of 12 and 18 is 6 and the LCM is 36. For two numbers, 6 × 36 = 216 = 12 × 18.

Questions

What is the difference between GCD and LCM?

The GCD is the biggest number that goes into all of your numbers. The LCM is the smallest number that all of your numbers go into. For 12 and 18 they are 6 and 36.

Is the GCD the same as the GCF?

Yes. Greatest common divisor, greatest common factor and highest common factor all name the same number.

Is 1 a prime number?

No. A prime has exactly two factors and 1 has only one. The smallest prime is 2, and it is the only even prime.

Last reviewed 2026-10-07. Report an incorrect result

Got another question?

Free, no account. Answers show how they were worked out.