Prime Factorization & GCD
Factor numbers into primes and find GCD, LCM and divisors.
How to use the Prime Factorization & GCD
- 1Enter one or more whole numbers.
- 2See prime factors, divisors and whether each number is prime.
- 3Get the GCD and LCM with the steps.
About Prime Factorization & GCD
The Prime Factorization & GCD tool breaks whole numbers into their prime factors and works out the greatest common divisor and least common multiple of several numbers at once. Enter numbers separated by commas or spaces, with up to 24 digits each. For every number you get its prime factorization in exponent form, a factor tree, whether it is prime, the number and sum of its divisors, and the divisors themselves when there aren't too many to list.
For two or more numbers, the GCD and LCM appear with the steps of the Euclidean algorithm, and the tool tells you when the numbers are coprime. Large numbers are factored with Pollard's rho method and tested with a deterministic Miller–Rabin primality test, so the answers are exact even for numbers far beyond what trial division could handle.
Use the prime factorization calculator to simplify fractions, find common denominators, check whether a number is prime, practice number theory for school or math competitions, or explore divisibility. It also helps with everyday problems, such as splitting items into equal groups or finding when two repeating schedules line up again.
Every whole number above 1 is either prime or a product of primes, and that product is unique apart from the order of the factors. This is the fundamental theorem of arithmetic, and it's why factorization is so useful. For example, 360 = 2³ × 3² × 5. The exponents give you the number of divisors right away: add 1 to each one and multiply, so (3 + 1)(2 + 1)(1 + 1) = 24.
Factorizations make GCD and LCM easy to see. Take 84 = 2² × 3 × 7 and 126 = 2 × 3² × 7. The GCD uses the lowest power of each shared prime, 2 × 3 × 7 = 42, and the LCM uses the highest power of each prime, 2² × 3² × 7 = 252. The product of the GCD and LCM always equals the product of the two numbers. Multiplying large primes is easy, but factoring the result is hard, and RSA encryption relies on exactly that difficulty.
Frequently asked questions
What is prime factorization?
It means writing a whole number as a product of prime numbers, such as 360 = 2³ × 3² × 5. By the fundamental theorem of arithmetic, every integer greater than 1 has exactly one such factorization, apart from the order of the factors.
How do I find the GCD and LCM from prime factors?
The GCD takes each prime the numbers share with its smallest exponent; the LCM takes every prime that appears with its largest exponent. For 12 = 2² × 3 and 18 = 2 × 3², the GCD is 2 × 3 = 6 and the LCM is 2² × 3² = 36.
How does the Euclidean algorithm work?
Divide the larger number by the smaller one and keep the remainder, then repeat with the smaller number and that remainder until the remainder is 0. The last non-zero remainder is the GCD: 48 = 2 × 18 + 12, 18 = 1 × 12 + 6, 12 = 2 × 6, so the GCD of 48 and 18 is 6.
Is 1 a prime number?
No. A prime has exactly two distinct divisors, 1 and itself, while 1 has only one. Leaving 1 out also keeps prime factorizations unique.
More in Math & Science
Plot functions, find roots and intersections, and explore with sliders.
Solve linear, quadratic, polynomial and systems of equations step by step.
Multiply, invert and find determinants, eigenvalues and more.