What this calculator does
Break any whole number down into the prime numbers that multiply to make it. A prime is a number with no divisors except 1 and itself, like 2, 3, 5 or 7. Every whole number above 1 can be written as primes multiplied together in exactly one way, apart from their order. That's its prime factorization. For example, 360 = 2 × 2 × 2 × 3 × 3 × 5. It's usually written in a shorter way as 2³ × 3² × 5, where the small raised number (the exponent) counts the repeats.
Think of the prime factorization as the number's building blocks. It helps with many other jobs: greatest common factors, least common multiples, simplifying fractions and roots, and counting divisors. Enter a whole number from 2 up to one quadrillion (10^15). The calculator divides by the smallest prime that fits, again and again. It shows each division as a step, the same ladder you'd write by hand. You get the factorization with exponents and a version written with ^ for typing. You also see how many different primes appear and how many divisors the number has.
Where it's used
Why this math matters outside the classroom:
- Simplifying fractions. Writing 84 = 2² × 3 × 7 and 126 = 2 × 3² × 7 shows their GCF is 2 × 3 × 7 = 42, so 84/126 = 2/3.
- Common denominators. Since 12 = 2² × 3 and 18 = 2 × 3², their LCM is 2² × 3² = 36, the least common denominator.
- Simplifying radicals. Factoring 72 as 2³ × 3² lets students simplify √72 to 6√2.
- Encryption. RSA encryption relies on how hard it is to find the two large prime factors of a number hundreds of digits long.
- Counting divisors. Because 360 = 2³ × 3² × 5, it has (3 + 1)(2 + 1)(1 + 1) = 24 divisors.
How to use it
- Type a whole number between 2 and 1,000,000,000,000,000.
- Read the prime factorization at the top, written with small raised exponents.
- Open the working to follow each division, or use the table to see each prime power on its own.
What the inputs mean
- Whole number to factor
- Only whole numbers of 2 or more have a prime factorization. The number 1 has no primes in it at all (mathematicians call it the empty product). 0 can be divided by every prime. So neither is accepted. For a negative number, factor its size and put a −1 in front.
Formula and method
n = p₁^e₁ × p₂^e₂ × … × pₖ^eₖ (p₁ < p₂ < … < pₖ prime) trial divisors only need to go up to √m number of divisors = (e₁ + 1)(e₂ + 1)…(eₖ + 1)
In the formulas, n is your number. p₁, p₂ and so on are its primes from smallest to largest, and e₁, e₂ and so on are how many times each one appears. k is the number of different primes, and m is whatever is left to factor. The method is called trial division. Start with the prime 2. While it divides the current number evenly, divide and write it down. Then move on to 3, then 5, 7, 11 and so on. Once a prime is used up, what's left has no smaller prime factors.
You can stop as soon as the trial divisor squared is bigger than what's left. Here's why. If m had two prime factors both bigger than √m (the square root of m), multiplying them would give more than m. That's impossible. So anything above 1 left at that point must be prime itself.
Behind the scenes, the calculator skips multiples of 2 and 3 after testing those two primes. It only tries numbers just below or just above a multiple of 6 (6k − 1 and 6k + 1). That keeps even a 15-digit prime quick to confirm. Only divisions that work appear in the working.
Worked example
Find the prime factorization of 360.
- 360 ÷ 2 = 180, then 180 ÷ 2 = 90, then 90 ÷ 2 = 45. The number 2 no longer divides 45.
- 45 ÷ 3 = 15, then 15 ÷ 3 = 5. The number 3 no longer divides 5.
- 5 is left. The next prime to try would be 5, but 5 × 5 = 25 is more than 5. So no smaller prime can divide it. 5 is prime itself, and the ladder is finished.
- The primes used were 2, 2, 2, 3, 3 and 5, so 360 = 2³ × 3² × 5.
Result: 360 = 2³ × 3² × 5. It has 3 different prime factors, 6 prime factors counting repeats, and (3 + 1)(2 + 1)(1 + 1) = 24 divisors.
Understanding the result
If the factorization is just the number itself, the number is prime. If a prime appears with exponent 1, the number can't be divided by that prime's square.
Two numbers share a common factor other than 1 exactly when their factorizations share a prime. Their greatest common factor uses the smaller exponent of each shared prime. Their least common multiple uses the larger exponent of every prime that appears in either.
A number is a perfect square when every exponent is even. It's a perfect cube when every exponent is a multiple of 3. For example, 360 is neither, but 3,600 = 2⁴ × 3² × 5² is a perfect square.
Assumptions and limitations
- The input is a whole number from 2 to 10^15. That's small enough to be stored and divided exactly.
- Larger numbers are turned away. At the top of the range, trial division needs up to about 3 × 10^7 trial divisors. Beyond that, a different method (such as Pollard's rho) is needed.
- When a number has many repeated factors, only the first 24 divisions are listed one by one. The rest are summed up.
- The working shows a division ladder rather than a drawn factor tree. Both find the same primes.
Frequently asked questions
Is a factor tree different from a division ladder?
Only in how it looks. A factor tree splits a number into any two factors. It keeps splitting the branches until every end is prime. A ladder always divides by the smallest prime. Since each number has only one prime factorization, both always end with the same primes.
Why is 1 not a prime number?
If 1 counted as prime, factorizations would stop being one of a kind. 6 could be written as 2 × 3, 1 × 2 × 3, 1 × 1 × 2 × 3 and so on. Leaving 1 out keeps each factorization unique, and that's what makes it useful.
How do I get the number of divisors from the factorization?
Add 1 to each exponent and multiply. Each divisor picks a power of every prime, from 0 up to its exponent. So 360 = 2³ × 3² × 5 has 4 × 3 × 2 = 24 divisors.
Can every number be factored this quickly?
Numbers in this range can. Factoring very large numbers, hundreds of digits long, is believed to be hard. Some public-key encryption (the kind that protects online payments) relies on that difficulty.
How this calculator is checked
Method: Fundamental theorem of arithmetic; trial division up to the square root of the remaining cofactor; divisor-count formula from the exponents. The calculation is covered by automated tests with known reference values and edge cases. Last updated 2026-10-18. Found a problem? Tell us.
Embed this calculator
Put this Prime Factorization Calculator on your own website or blog for free. Paste this code where you want it to appear: