Skip to content
Wagonsmith

LCM Calculator

Enter two to ten whole numbers and this LCM calculator returns their least common multiple and greatest common factor, with the prime factorization steps.

Results

Least common multiple (LCM)
-
Greatest common factor (GCF)
-

How to use the LCM calculator

  1. Type two to ten positive whole numbers in the box. Separate them with commas, spaces or line breaks.
  2. The least common multiple and greatest common factor appear immediately. There is no calculate button to press.
  3. Open the steps underneath to see each number written as a product of primes, a table of the prime powers, and how the LCM and GCF are built from that table.
  4. Use the copy button to grab both answers, or Reset to start over.

How the LCM is found

The least common multiple of a set of numbers is the smallest positive number that each of them divides evenly. Two methods are common. The calculator shows the first and uses the second to guarantee exact answers for very large inputs.

Worked example 1: LCM and GCF of 4, 6 and 8

Factor each number: 4 = 2², 6 = 2 × 3, and 8 = 2³. The highest power of 2 is 2³ and the highest power of 3 is 3¹, so the LCM is 2³ × 3 = 8 × 3 = 24. For the GCF, the lowest power of 2 is 2¹ and 3 is missing from 4 and 8, so it drops out. The GCF is 2. As a check, 24 ÷ 4 = 6, 24 ÷ 6 = 4 and 24 ÷ 8 = 3, all whole numbers.

Worked example 2: LCM and GCF of 12, 18 and 30

Here 12 = 2² × 3, 18 = 2 × 3², and 30 = 2 × 3 × 5. The highest powers are 2², 3² and 5, so the LCM is 4 × 9 × 5 = 180. The lowest powers are 2 and 3, and 5 is missing from 12 and 18, so the GCF is 2 × 3 = 6. Check: 180 ÷ 12 = 15, 180 ÷ 18 = 10, and 180 ÷ 30 = 6.

Where the LCM is useful

Limits

The tool accepts 2 to 10 positive whole numbers of up to 30 digits. It uses big-integer arithmetic, so results stay exact even above 9,007,199,254,740,991, the largest integer that ordinary JavaScript numbers can store without rounding. The prime factorization steps are shown when every input is 1 trillion or less, because factoring huge numbers by trial division would make the page slow. For larger inputs the LCM and GCF are still exact.

Frequently asked questions

What is the least common multiple?

The least common multiple (LCM) of a set of whole numbers is the smallest positive number that every number in the set divides into evenly. For 4, 6 and 8 it is 24, because 24 is the first number that appears in the multiplication tables of all three.

How do I find the LCM using prime factorization?

Write each number as a product of primes, then for every prime that appears take its highest power from any of the numbers, and multiply those together. For 4 (2 x 2), 6 (2 x 3) and 8 (2 x 2 x 2), the highest power of 2 is 2 cubed and the highest power of 3 is 3, so the LCM is 8 x 3 = 24.

What is the difference between LCM and GCF?

The LCM is the smallest number all inputs divide into, so it is at least as large as the biggest input. The greatest common factor (GCF, also called GCD or HCF) is the largest number that divides all inputs, so it is no larger than the smallest input. For two numbers a and b, LCM x GCF = a x b.

How many numbers can I enter, and how big can they be?

You can enter 2 to 10 positive whole numbers of up to 30 digits each. The tool uses exact big-integer arithmetic, so results beyond the ordinary JavaScript safe limit of 9,007,199,254,740,991 stay correct. Step-by-step prime factorization is shown only when every number is 1 trillion or smaller.

Can I use 0, negatives or decimals?

No. The LCM is defined here for positive whole numbers. Zero, negative numbers and decimals are rejected with a message so you can correct the entry.