Prime Factorization Calculator

Enter a whole number to write it as a product of prime numbers, follow the factor tree step by step, and see whether the number is prime and how many divisors it has.

Your results

–

Save this calculation and come back to it any time. Members only — $5 every 3 months, ad-free.

Become a member

How to use the prime factorization calculator

  1. Enter a whole number from 1 to 1,000,000,000,000,000 (10¹⁵).
  2. Read the factorization at the top, written with exponents, such as 2³ × 3² × 5.
  3. Check the Prime? line. If your number is prime, its factorization is just the number itself.
  4. Follow the factor tree to see each division, and use the table to see what each prime contributes.

How prime factorization works

Every whole number greater than 1 is either prime or a product of primes, and that product is the same however you find it. This is the fundamental theorem of arithmetic. The calculator uses trial division:

1. Divide n by 2 as many times as it goes evenly. 2. Repeat with 3, then 5, 7, 11, 13, … (numbers of the form 6k ± 1). 3. Stop once the divisor squared is larger than what is left. 4. If what is left is more than 1, it is prime. n = p₁^e₁ × p₂^e₂ × … Divisors = (e₁ + 1)(e₂ + 1)…

Step 3 works because a number that is not prime must have a factor no larger than its square root. Testing only 2, 3 and numbers of the form 6k ± 1 skips every multiple of 2 and 3, which cuts the work by two thirds without missing a prime.

Worked example

The calculator starts with 360.

  1. 360 = 2 × 180
  2. 180 = 2 × 90
  3. 90 = 2 × 45. 45 is odd, so move on to 3.
  4. 45 = 3 × 15
  5. 15 = 3 × 5. 5 is prime, so the tree ends.
  6. Collect the primes: 360 = 2 × 2 × 2 × 3 × 3 × 5 = 2³ × 3² × 5.

From the exponents, 360 has (3 + 1)(2 + 1)(1 + 1) = 4 × 3 × 2 = 24 divisors. You can also multiply the primes back together to check: 8 × 9 × 5 = 360.

Factor trees: different routes, same answer

You don't have to start with the smallest prime. Splitting 360 as 36 × 10 gives 36 = 6 × 6 = 2 × 3 × 2 × 3 and 10 = 2 × 5, which is the same set of primes: three 2s, two 3s and one 5. The calculator always takes the smallest prime first, which gives a tidy tree that never needs a second look.

Number Prime factorization Divisors
12 2² × 3 6
60 2² × 3 × 5 12
97 97 (prime) 2
360 2³ × 3² × 5 24
1,001 7 × 11 × 13 8
1,024 2¹⁰ 11

What you can do with it

Prime factorizations make other problems quick. The greatest common factor of two numbers uses the primes they share, each to its smaller power, and the least common multiple uses every prime, each to its larger power. Use the GCF calculator and the LCM calculator to see both worked out. A number is a perfect square exactly when every exponent is even, and a perfect cube when every exponent is a multiple of 3.

Frequently asked questions

Is 1 a prime number?

No. A prime has exactly two different factors, 1 and itself, and 1 has only one. Leaving 1 out also keeps factorizations unique; otherwise you could add any number of 1s to a product.

How does the calculator know a large number is prime?

It tests every possible divisor up to the square root. For a number near 10¹⁵ that means divisors up to about 31.6 million, which takes your browser a fraction of a second. If none divides evenly, the number is prime.

Why is 2 the only even prime?

Every other even number is divisible by 2, so it has at least three factors: 1, 2 and itself. That's why trial division handles 2 first and then only tests odd numbers.

Can a negative number be factored into primes?

Primes are positive, so factor the positive version and put −1 in front. For example, −360 = −1 × 2³ × 3² × 5. The calculator asks for a positive number for this reason.

Related calculators

  • Factor Calculator — Every factor and factor pair of a whole number, with the count, the sum and prime, perfect or abundant checks.
  • GCF Calculator — Greatest common factor of two or more whole numbers, with Euclid's algorithm and a prime factorization check.
  • LCM Calculator — Least common multiple of two or more whole numbers, worked out by prime factorization and by the GCF method.
  • Common Factor Calculator — Every factor shared by two or more whole numbers, with the greatest common factor and each number's factor list.

Results are calculated in your browser. Double-check anything important before you rely on it. See our disclaimer.