How to use the calculator
Enter between 2 and 50 positive whole numbers, separated by commas, spaces or new lines, and press Calculate. Each number can be as large as 1,000,000,000,000 (one trillion). Do not use thousands separators, because a comma starts a new number.
The result shows:
- the greatest common factor (GCF), also called the greatest common divisor (GCD) or highest common factor (HCF)
- the least common multiple (LCM), written out in full even when it has dozens of digits
- the prime factorization of the LCM and of every number you entered
How it works
The GCF is found with the Euclidean algorithm: replace the larger number by the remainder of dividing it by the smaller one, and repeat until the remainder is zero. The last non-zero value is the GCF. For more than two numbers, the GCF of the first two is combined with the third, and so on.
The LCM of two numbers is a × b ÷ GCF(a, b), applied one number at a time. Whole-number arithmetic with no size limit is used, so the LCM is exact even when it is far larger than a normal calculator can display.
Prime factors are found by trial division: divide by 2, then 3, then by candidates up to the square root of what is left.
Worked example
Take 12, 18 and 30.
- 12 = 2² × 3
- 18 = 2 × 3²
- 30 = 2 × 3 × 5
The GCF takes each prime that appears in every number, with its smallest power: 2 × 3 = 6.
The LCM takes every prime that appears in any number, with its largest power: 2² × 3² × 5 = 180.
You can check the link between the two for a pair of numbers: for 12 and 18, the GCF is 6 and the LCM is 36, and 6 × 36 = 216 = 12 × 18.
Good to know
- If the GCF is 1, the numbers are called coprime (or relatively prime): they share no prime factor.
- The LCM is useful for adding fractions (it gives the lowest common denominator) and for finding when repeating events line up again.
- The GCF is useful for simplifying fractions and ratios and for splitting things into equal groups.
- The number 1 has no prime factors, so it never changes the LCM and always makes the GCF equal to 1.