Prime Factorization Calculator

About this calculator

The Prime Factorization Calculator writes any whole number as a product of primes, in expanded form and with exponents. You also get the trial division steps, a factor tree and a prime check.

Numbers up to 18 digits are factored exactly with BigInt.

A whole number of 2 or more, up to 18 digits.
Embed this calculator

Paste this code into a Custom HTML block on your site. The calculator fits the width of the block. Adjust the height in the code if you want more room for results.

Find this widget in the publisher directory

What is a prime number?

A prime number is a whole number greater than 1 whose only positive divisors are 1 and itself. The first few are 2, 3, 5, 7, 11, 13 and 17. A number with more divisors than that is called composite. The number 2 is the only even prime, and 1 is neither prime nor composite.

What is prime factorization?

The fundamental theorem of arithmetic says every whole number greater than 1 is either prime or can be written as a product of primes, and that product is unique apart from the order of the factors. For example, 60 = 5 × 3 × 2 × 2, and no other collection of primes multiplies to 60. Writing repeated primes with exponents gives the compact form 22 × 3 × 5.

Method 1: trial division

Divide by the smallest prime that goes in evenly, then repeat on the quotient until you reach 1. Here is 820:

StepResult
820 ÷ 2410
410 ÷ 2205
205 ÷ 541
41 ÷ 411

So 820 = 2 × 2 × 5 × 41 = 22 × 5 × 41. You can stop trial dividing once the next prime squared is bigger than what remains, because the remainder must then itself be prime. Here 41 is smaller than 7 squared (49), so after 2, 3, 5 fail to give a further split, 41 is declared prime.

Method 2: the factor tree

Split the number into any two factors, then split each of those, until every leaf is prime. The branches can differ (820 can start as 2 × 410 or as 4 × 205), but the leaves always come out the same: 2, 2, 5 and 41. This calculator draws the tree by peeling off the smallest prime at each level.

How to check whether a number is prime

Try dividing by every prime up to the square root of the number. If none divides it evenly, the number is prime. To test 97, the square root is just under 10, so you only need to try 2, 3, 5 and 7. None works, so 97 is prime. For very large numbers the calculator switches to a faster probabilistic test that is deterministic for numbers of this size.

Common prime factorizations

NumberPrime factorization
1222 × 3
3622 × 32
6022 × 3 × 5
10022 × 52
36023 × 32 × 5
1,00023 × 53

Why it matters

  • It gives the greatest common factor and least common multiple of any set of numbers by comparing exponents.
  • It counts divisors: add one to each exponent and multiply. For 360 that is 4 × 3 × 2 = 24 divisors.
  • Modern public-key encryption relies on the fact that multiplying two huge primes is easy while recovering them from the product is hard.

Tips

If the last digit is even, 2 is a factor; if the digits add to a multiple of 3, so is 3; if the last digit is 0 or 5, so is 5. Spotting these quickly speeds up any manual factorization.

Reading the results

The first line shows the factorization with every prime repeated, the way a factor tree ends. The second line shows the compact exponent form, where a caret means a power. The distinct count tells you how many different primes appear, and the repeated count tells you how many leaves a factor tree would have. For 820 those counts are 3 and 4.

Using the factorization

With two factorizations side by side you can read off both the GCF (smallest exponent of each shared prime) and the LCM (largest exponent of every prime). You can also tell instantly whether a number is a perfect square, since every exponent will be even, or a perfect cube, where every exponent is a multiple of three. For example 3,600 = 24 × 32 × 52 is a perfect square, and its square root is 22 × 3 × 5 = 60.

Frequently asked questions

What is the prime factorization of 60?

60 = 2 × 2 × 3 × 5, written with exponents as 22 × 3 × 5.

Is the prime factorization of a number unique?

Yes. Apart from the order of the factors, every integer greater than 1 has exactly one prime factorization.

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. The calculator reports this directly in the Is it prime row.

Why is 1 not prime?

A prime must have exactly two distinct positive divisors. The number 1 has just one, and counting it as prime would break the uniqueness of factorization.

Formulas and sample results on this page were checked against independent references. Page last reviewed or updated . How we verify calculators. Project led by Shaun Connell.