Home › Math › Prime Factorization Calculator

Prime Factorization Calculator

Use this free prime factorization calculator to break any whole number up to 1 trillion (10^12) into its prime factors. Type a number and it shows the factorization with exponents, a factor tree that walks through the splitting step by step, and a clear verdict on whether the number is prime or composite. It runs entirely in your browser, with no sign-up and nothing to install.

360 = 2³ × 3² × 5
Composite · 3 distinct prime factors · 6 prime factors with repetition

Enter a whole number from 2 to 1,000,000,000,000. The numbers 0 and 1 have no prime factorization, and negative numbers are not accepted.

Factor tree

Each branch splits a number into two factors until only primes remain. The primes at the bottom multiply back to 360.

How it works

A prime number is a whole number greater than 1 that can only be divided evenly by 1 and itself: 2, 3, 5, 7, 11, 13, 17, 19 and so on. Every other whole number greater than 1 is composite, meaning it can be built by multiplying primes together. Prime factorization is the process of finding exactly which primes, multiplied together, make a given number — and the remarkable fact, called the fundamental theorem of arithmetic, is that there is only one such factorization for each number (ignoring the order of the factors). That uniqueness makes prime factors the "atoms" of arithmetic: every number has one and only one recipe.

The calculator finds the factors by trial division, the oldest and most reliable method. It starts with the smallest prime, 2, and divides the number by 2 as many times as it divides evenly, recording each 2. Then it tries 3, 5, 7 and so on, up to the square root of what is left — it only needs to go that far, because any factor larger than the square root has a partner factor smaller than it that would already have been found. When the remainder is 1, the recorded primes are the complete factorization; when the remainder is itself prime, it is the last factor. For a number as large as 1 trillion, the square root is 1 million, so the calculator tests at most about 78,000 primes — a fraction of a second in a browser.

The result is shown in two forms. The expanded form lists every prime factor with repetition, so 360 appears as 2 × 2 × 2 × 3 × 3 × 5. The compact form groups repeated factors with exponents, so the same answer reads 2³ × 3² × 5. The result panel also counts the distinct primes and the total number of factors, and states plainly whether the number is prime or composite. A prime number has only itself as a factor, so 97 factors as just 97.

The factor tree beside the calculator shows the same process as a picture. Start with the whole number at the top and split it into any two factors, then split each factor again until every branch ends in a prime. For 360, one natural split is 36 × 10: 36 splits into 6 × 6, each 6 into 2 × 3, and 10 into 2 × 5, leaving the primes 2, 2, 2, 3, 3 and 5 at the bottom. The tree depends on the first split you choose, but the primes at the bottom are always the same — the fundamental theorem in action. The calculator draws the tree automatically, splitting each composite number into its smallest prime factor and its partner.

Two special cases deserve an honest answer instead of a made-up one. The number 1 has no prime factorization: it is neither prime nor composite and has no prime factors. Zero cannot be written as a product of primes either, because any product that includes zero is zero. Negative numbers are not accepted, because prime factorization is defined for positive whole numbers; to factor a negative number, factor its positive part and remember the minus sign. The calculator shows a friendly message for each of these cases instead of a wrong or empty result.

Prime factors are useful far beyond homework. They are the fastest way to find the greatest common factor of two numbers — take the primes they share, at the lowest exponent in both — and the least common multiple, where you take the highest exponent of each prime. They simplify fractions, because cancelling means dividing the top and bottom by their common prime factors. And they sit at the heart of modern cryptography: the encryption that protects online banking relies on multiplying two large primes being easy while factoring their product back apart is enormously hard.

Worked example

Factor 360 by hand, the way the calculator does it. Start with 2: 360 is even, so divide by 2 to get 180, then 90, then 45. Now 45 is odd, so 2 is finished — it divided 360 three times, giving three factors of 2. Move to 3: 45 divided by 3 is 15, and 15 divided by 3 is 5, which is prime and the final factor. The full list is 2, 2, 2, 3, 3, 5, and the compact form groups the repeats: 360 = 2³ × 3² × 5.

Check the answer by multiplying back: 2³ is 8, 3² is 9, 8 × 9 = 72, and 72 × 5 = 360. The factor tree shows the same splits as a diagram, with 360 at the top branching down to the six primes. Type 360 into the calculator and it gives the identical result: 360 = 2³ × 3² × 5, marked composite, with 3 distinct prime factors and 6 prime factors counting repetition.

For a contrast, try 97. The calculator tests 2 (97 is odd), 3 (9 + 7 = 16, not divisible by 3), 5 (it does not end in 0 or 5) and 7 (7 × 13 = 91 and 7 × 14 = 98). The square root of 97 is about 9.8, so only the primes 2, 3, 5 and 7 need testing, and none of them divide 97. The verdict is prime.

FAQ

What is prime factorization?

Prime factorization is writing a whole number as a product of prime numbers — numbers divisible only by 1 and themselves. For example, 360 = 2³ × 3² × 5. Every whole number greater than 1 has exactly one prime factorization, which is why it is called the fundamental theorem of arithmetic.

What is a factor tree?

A factor tree breaks a number down step by step. Split the number into any two factors, then split each of those until only prime numbers are left at the bottom. The primes at the ends of the branches multiply together to give the original number.

What is the prime factorization of 1 and 0?

Neither has one. The number 1 is not prime and has no prime factors at all, and 0 cannot be written as a product of primes because any product involving 0 is 0. This calculator explains that instead of giving a misleading answer.

How do I know if a number is prime?

A prime number has exactly two factors: 1 and itself. To test a number by hand, try dividing it by every prime up to its square root — 2, 3, 5, 7, 11 and so on. If none divide it evenly, the number is prime. This calculator runs that test for you and states the verdict.

Why is prime factorization useful?

Prime factors are the fastest route to the greatest common factor and the least common multiple of two numbers, and they make fractions easier to simplify. They also sit at the heart of modern cryptography: much online encryption rests on how hard it is to factor very large numbers.