Prime Factorization Calculator

Enter a whole number from 2 to 1,000,000,000,000 to see it written as a product of primes.

Updated

Embed this calculator

Paste this code into your page. The calculator runs inside the frame and links back to the full version.

Keep the credit link in place. Do not resell the calculator.

Formula

Trial division: divide by 2, then by odd numbers 3, 5, 7, ... while the divisor squared is at most what remains; anything left above 1 is prime. The number of divisors is (e1 + 1) × (e2 + 1) × ... for exponents e1, e2, ....

Worked example

360 ÷ 2 = 180, ÷ 2 = 90, ÷ 2 = 45, then 45 ÷ 3 = 15, ÷ 3 = 5, and 5 is prime. So 360 = 2^3 x 3^2 x 5, with 3 distinct primes and (3+1)(2+1)(1+1) = 24 divisors.

Frequently asked questions

What is prime factorization?

It is writing a whole number as a product of prime numbers. Every number above 1 has exactly one such product. For example, 360 = 2^3 x 3^2 x 5, which means 2 × 2 × 2 × 3 × 3 × 5.

How does trial division find the factors?

Divide by 2, then by each odd number 3, 5, 7 and so on, as long as it divides evenly, and stop when the divisor squared exceeds what is left. Whatever remains above 1 is itself prime. For 360 the steps are 360 ÷ 2 ÷ 2 ÷ 2 = 45, then 45 ÷ 3 ÷ 3 = 5.

How many divisors does a number have?

Add 1 to each exponent and multiply the results. For 360 = 2^3 x 3^2 x 5 that is (3+1) × (2+1) × (1+1) = 24 divisors.

What if the number is prime?

A prime is its own only prime factor, so the answer is the number itself and it has exactly 2 divisors. 97 is an example. The number 1 has no prime factors, so it is not accepted.