Skip to content
Mathematics

GCD, LCM and prime factors

Find the greatest common divisor, least common multiple and prime factors of up to twelve whole numbers.

Free & no registration Calculated in your browser
01

Your inputs

The starting values are an example.

Separate with semicolons. Up to twelve values, each between −1 billion and 1 billion.

Decimals: 12.5 · Thousands: 1,234.56. Follow the field instructions for lists.

02

Your result

Enter your values and select Calculate.

Your calculation will appear here.

Your result will include the relevant values and units.

Understand the calculation

Formula and example

How it is calculated

GCD(a,b) = GCD(b,a mod b). For a,b ≠ 0, LCM(a,b) = |a·b|/GCD(a,b).

Worked example

For 12, 18 and 30, the GCD is 6 and the LCM is 180. Prime factors: 12 = 2²·3, 18 = 2·3² and 30 = 2·3·5.

Things to check

  • Signs do not change the GCD or LCM. The number 1 has no prime factors; 0 has no prime factorisation.
  • The LCM is returned as an exact integer, even beyond the usual floating-point precision.

Frequently asked questions

What happens with a zero?

GCD(a,0) is |a|. In this tool, GCD(0,0) and any LCM with a zero input are defined as 0.