Guide
GCD, LCM and prime factorization of whole numbers
The greatest common divisor and the least common multiple are the working tools of fractions and ratios: the GCD simplifies a fraction and the LCM finds a common denominator. They are also the entry point to number theory through prime factorization. This calculator gives both for a list of whole numbers, with the prime factors, divisor counts and, for two numbers, every step of Euclid’s algorithm, using exact big-integer arithmetic so large inputs are not rounded.
How the GCD and LCM are found
The GCD comes from Euclid’s algorithm: divide the larger number by the smaller, replace the pair with the smaller number and the remainder, and repeat until the remainder is 0. The last non-zero remainder is the GCD. The LCM of two numbers is a × b ÷ GCD, and for a list the tool combines the numbers one after another. A GCD of 1 means the numbers are coprime, which the page states when there are two or more numbers.
Using the tool
Enter whole numbers separated by spaces, commas or line breaks, from one to twenty, each with at most thirty digits. The page opens on 48, 180 and 360 and shows GCD 12, LCM 720 and a table of prime factorizations: 48 = 2⁴ × 3 with 10 divisors, 180 = 2² × 3² × 5 with 18, and 360 = 2³ × 3² × 5 with 24. The menu can limit the output to GCD and LCM only. Sample chips load four examples.
Euclid’s steps
With exactly two positive numbers the page prints the algorithm line by line. For 1071 and 462 it shows 1071 = 2 × 462 + 147, then 462 = 3 × 147 + 21, then 147 = 7 × 21 + 0, so the GCD is 21 and the LCM is 1071 × 462 ÷ 21 = 23,562. Three divisions suffice; the method never needs more than about five times the number of digits in the smaller number, which is why it is fast even for large inputs.
Factoring large numbers
Small primes are divided out first, then the Miller-Rabin test checks whether what remains is prime, and Pollard’s rho splits the rest. This handles typical numbers instantly: 600851475143, the number from a well-known programming puzzle, becomes 71 × 839 × 1471 × 6857, with 16 divisors. Numbers of 25 digits or more are not factored here, only tested for primality, and a product of two very large primes can still be out of reach.
Single numbers and divisors
If you enter one number below a trillion the tool also lists all its divisors, their sum and a classification. For 28 the divisors are 1, 2, 4, 7, 14 and 28; they add to 56, so the proper divisors sum to 28 and the number is perfect. 600851475143 has a divisor sum of 610,544,148,480, which is less than twice the number, so it is deficient. Long divisor lists are shortened to the first thirty.
Edge cases
Zero is divisible by every number, so the GCD ignores it and the LCM with zero is 0 by convention; the page says so. The number 1 has no prime factors, and a prime has itself as the only factor. Negative numbers, decimals and fractions are rejected with a message that names the offending item. Leading zeros are fine. Because the arithmetic is exact, a thirty-digit GCD is as reliable as a two-digit one.
Limits
The tool handles whole numbers only. It does not factor polynomials or work modulo a number, and it does not give the extended Euclidean coefficients. Factoring very large numbers is a hard problem in general, so a failure message is a limit of the browser, not a sign that the number is special. For fractions with several denominators, find the LCM of the denominators.
Related tools
- Fraction Calculator puts the GCD to work in simplifying fractions.
- Percentage Calculator is the next stop for everyday ratio questions.
- Permutation and Combination Calculator counts arrangements using the same big integers.
- Random Number Generator produces whole numbers to test the GCD on.
Checked against the current version of the GCD and LCM Calculator on .

