Prime Factorization Calculator
Whether a number is prime, its prime factors, and all its divisors.
Good to know. Every whole number above 1 has exactly one set of prime factors, the way every person has one set of DNA.
How it works
In plain words
Divide by the smallest prime that goes in, 2 if the number is even, and keep dividing the result by primes until 1 is left. The primes you divided by are the prime factors. A number is prime if nothing but 1 and itself divides it.
The formula
n = p₁^a × p₂^b × … number of divisors = (a + 1) × (b + 1) × …
Worked example
360 ÷ 2 = 180, ÷ 2 = 90, ÷ 2 = 45, ÷ 3 = 15, ÷ 3 = 5, and 5 is prime. So 360 = 2³ × 3² × 5, with (3 + 1) × (2 + 1) × (1 + 1) = 24 divisors.
Sources
No outside data or rates: this is plain arithmetic.
3 automated tests check its answers on every change.
About the prime factorization calculator
A prime number has exactly two divisors: 1 and itself, like 2, 3, 5, 7, 11 and 13. Every other whole number above 1 can be written as a product of primes in exactly one way, its prime factorization. This calculator finds it, tells you whether the number is prime, and lists all its divisors.
The method is repeated division. Divide by 2 as long as the number is even, then try 3, 5, 7 and so on. You only need to try primes up to the square root of what is left: if nothing up to there divides it, what is left is prime. The calculator does this for numbers up to a trillion in a moment.
Prime factors make other problems easy. The greatest common factor of two numbers uses the primes they share; the least common multiple uses every prime at its highest power; and a fraction is fully simplified when top and bottom share no prime. The number of divisors comes straight from the powers: add one to each and multiply.
Primes also protect the internet. Encryption like RSA relies on the fact that multiplying two huge primes is easy, but factoring the result back into them would take today’s computers longer than the age of the universe.
Questions people ask
How do I find the prime factors of a number?
Keep dividing by the smallest prime that goes in until you reach 1. For 60: 60 ÷ 2 = 30, ÷ 2 = 15, ÷ 3 = 5, so 60 = 2² × 3 × 5.
Is 1 a prime number?
No. A prime has exactly two divisors, and 1 has only one. The smallest prime is 2, the only even one.
How do I know if a number is prime?
Check whether any prime up to its square root divides it. If none does, it is prime. For 97, try 2, 3, 5 and 7: none divide it, so 97 is prime.