Skip to content

Prime Factorization Calculator with Factor Tree

Break any whole number up to 10¹⁵ into prime factors with exponents, a factor tree, divisor count and a prime test.

Your details

From 2 to 10¹⁵ (1,000,000,000,000,000). Thousands separators are allowed.

Results update as you type

Prime factorization

2³ × 3² × 5

Is it prime?
No — 360 is composite
Expanded product
2 × 2 × 2 × 3 × 3 × 5
Distinct prime factors
2, 3, 5
Prime factors counted with multiplicity
6
Number of divisors τ(n)
24
Sum of divisors σ(n)
1,170
All divisors
1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 18, 20, 24, 30, 36, 40, 45, 60, 72, 90, 120, 180, 360
Previous prime
359
Next prime
367

Step-by-step solution
  1. 360 = 2 × 180
  2. 180 = 2 × 90
  3. 90 = 2 × 45
  4. 45 = 3 × 15
  5. 15 = 3 × 5
  6. 5 is prime, so the factor tree stops here.
  7. Result: 360 = 2³ × 3² × 5

Prime powers

Every whole number greater than 1 is either a prime (divisible only by 1 and itself) or a product of primes, and that product is unique apart from the order of the factors. This is the fundamental theorem of arithmetic, and the product is called the number's prime factorization. For example 360=23×32×5360 = 2^{3} \times 3^{2} \times 5.

This prime factorization calculator finds that product for any whole number up to 101510^{15} (a thousand trillion). It shows the result in exponent form, the expanded product, the list of distinct prime factors, a step-by-step factor tree, and the arithmetic facts that follow from the factorization: the number of divisors, the sum of divisors and, for smaller results, the full list of divisors.

It also answers the simple question "is it prime?". If the number is prime, the calculator says so and explains why; if not, it gives the nearest primes below and above it. That makes the page a quick prime number checker as well as a prime factor calculator, and a companion to the GCD and LCM calculator, which uses factorizations to compare several numbers at once.

How to use this calculator

  1. Type a whole number between 2 and 1,000,000,000,000,000 in the box. Commas or spaces between groups of three digits are accepted.
  2. Read the prime factorization at the top, written with exponents, such as 23×32×52^3 \times 3^2 \times 5.
  3. Check Is it prime? for a yes/no answer, and the previous and next primes.
  4. Open the steps to follow the factor tree: at each line the smallest prime factor is split off, until the last factor is itself prime.
  5. Use the table of prime powers, the divisor count and the divisor sum for exercises on divisors, perfect numbers or simplifying square roots.

The formula

If n=p1e1p2e2⋯pkekn = p_1^{e_1} p_2^{e_2} \cdots p_k^{e_k} with distinct primes pip_i, then every divisor of nn has the form p1a1⋯pkakp_1^{a_1} \cdots p_k^{a_k} with 0≤ai≤ei0 \le a_i \le e_i. Counting and adding them gives

τ(n)=∏i=1k(ei+1),σ(n)=∏i=1kpi ei+1−1pi−1.\tau(n) = \prod_{i=1}^{k} (e_i + 1), \qquad \sigma(n) = \prod_{i=1}^{k} \frac{p_i^{\,e_i + 1} - 1}{p_i - 1}.

How the factors are found. The calculator first divides by 2, 3 and 5, then by the numbers coprime to 30 (a "wheel" that skips multiples of 2, 3 and 5) up to 10510^5. Any factor left over above 10510^5 is checked with the Miller–Rabin test using the first 13 primes as bases, which is proven to give no false answer below 3.3×10243.3 \times 10^{24}. If that cofactor is composite, Pollard's rho method splits it: it iterates x↦x2+c(modm)x \mapsto x^2 + c \pmod{m} and finds a factor as gcd⁡(∣xi−xj∣,m)\gcd(|x_i - x_j|, m) when the sequence repeats modulo a hidden prime. All arithmetic is done with exact integers.

Worked example

A classic: 360. Split off the smallest prime each time: 360=2×180360 = 2 \times 180, 180=2×90180 = 2 \times 90, 90=2×4590 = 2 \times 45, 45=3×1545 = 3 \times 15, 15=3×515 = 3 \times 5, and 5 is prime. So 360=23×32×5360 = 2^{3} \times 3^{2} \times 5. It has (3+1)(2+1)(1+1)=24(3+1)(2+1)(1+1) = 24 divisors, and their sum is σ(360)=15×13×6=1170\sigma(360) = 15 \times 13 \times 6 = 1170.

A squarefree number: 1001 =7×11×13= 7 \times 11 \times 13. Every exponent is 1, so it has 23=82^3 = 8 divisors.

A large number: 600,851,475,143 =71×839×1471×6857= 71 \times 839 \times 1471 \times 6857, found in a fraction of a second. Likewise 1,000,036,000,099=1000003×10000331{,}000{,}036{,}000{,}099 = 1000003 \times 1000033, a product of two seven-digit primes that Pollard's rho separates.

Is 97 prime? No prime up to 97≈9.8\sqrt{97} \approx 9.8 (2, 3, 5, 7) divides it, so yes; the next prime is 101.

Factor tree or division ladder?

A factor tree writes the number at the top and splits it into any two factors, then splits each branch again until every leaf is prime. Two students can draw different trees for 360 (say 36×1036 \times 10 or 8×458 \times 45), but the leaves always give the same primes — that is the uniqueness part of the fundamental theorem. The calculator draws the most systematic version, the division ladder: it always splits off the smallest prime, so each step reads "number = prime × what is left". Reading the primes down the left side gives the factorization.

What the factorization is used for

  • Simplifying fractions and roots: 360=22⋅32⋅10=610\sqrt{360} = \sqrt{2^2 \cdot 3^2 \cdot 10} = 6\sqrt{10}. See the square root calculator.
  • GCD and LCM: take the lowest or highest power of each common prime.
  • Divisor questions: perfect numbers satisfy σ(n)=2n\sigma(n) = 2n (for 28: σ=56\sigma = 56); a number is a perfect square exactly when every exponent is even.
  • Cryptography: RSA relies on the fact that multiplying two large primes is easy while factoring the product is hard. Numbers up to 101510^{15} are small enough to factor instantly; RSA moduli have hundreds of digits.

Frequently asked questions

How do I know if a number is prime?

Try dividing it by every prime up to its square root. If none divides it, it is prime. For 97 you only need to test 2, 3, 5 and 7. For large numbers the calculator uses the Miller–Rabin test, which is exact for every number this page accepts.

Is 1 a prime number?

No. A prime has exactly two divisors, 1 and itself, and 1 has only one. Excluding 1 is what keeps prime factorizations unique; otherwise you could multiply by 1 as many times as you like.

What is the difference between factors and prime factors?

Factors (divisors) of 12 are 1, 2, 3, 4, 6 and 12. Its prime factors are only 2 and 3, and the prime factorization 2² × 3 builds all six divisors from them.

Why do I get a different factor tree than my teacher?

A factor tree can start with any pair of factors, so trees can look different. The primes at the ends of the branches are always the same, with the same exponents.

How large a number can I factor?

Up to 10¹⁵. Every result is exact: trial division handles small factors and Pollard’s rho splits the rest, so even a product of two seven-digit primes is factored almost instantly.

Sources

Last updated:

More Math calculators

People also use