Prime Factorization Calculator

Break any whole number into its prime factors, with the full factor tree, every divisor, and a primality check.

How to use this calculator

  1. 1Enter any whole number from 2 upward.
  2. 2Read the factorisation in exponent form, or follow the factor tree to see each division.
  3. 3The divisor list shows every number that divides evenly, paired with its complement.

How the calculation works

n = p₁^a₁ × p₂^a₂ × … × pₖ^aₖ Number of divisors = (a₁+1)(a₂+1)…(aₖ+1)
pᵢ
A distinct prime factor
aᵢ
How many times that prime divides the number

The fundamental theorem of arithmetic guarantees this decomposition exists and is unique up to ordering.

Factorisation here is by trial division up to √n, which is more than fast enough for numbers a person types. Cryptographic-scale factorisation is a genuinely hard problem — that difficulty is what RSA encryption rests on.

The divisor-count formula follows because each divisor is formed by choosing an exponent from 0 to aᵢ for every prime independently.

Worked example

Factorising 5040

  1. 1.Divide by 2 repeatedly: 5040 → 2520 → 1260 → 630 → 315. That is 2⁴.
  2. 2.315 divides by 3 twice: 315 → 105 → 35. That is 3².
  3. 3.35 divides by 5 once, leaving 7, which is prime.
  4. 4.So 5040 = 2⁴ × 3² × 5 × 7, and it has (4+1)(2+1)(1+1)(1+1) = 60 divisors.

Result: 2⁴ × 3² × 5 × 7

What a prime factorization is

Every whole number greater than 1 is either prime — divisible only by 1 and itself — or it can be broken down into a unique product of prime numbers. That uniqueness is not a coincidence; it is a proven fact of arithmetic called the fundamental theorem of arithmetic, and it is the reason a factor tree always ends up at the same set of primes no matter which branch you split first.

Why prime factors matter beyond the classroom

Breaking a number into its prime building blocks turns out to be quietly load-bearing across several fields.

  • Cryptographymodern encryption schemes like RSA rely on the fact that multiplying two large primes together is fast, while factoring the huge result back apart is, with current computers, extraordinarily slow.
  • Simplifying fractions and finding GCF/LCMboth calculations reduce to comparing the prime factorizations of the numbers involved.
  • Hash tables in computer scienceseveral hashing and array-sizing techniques deliberately use prime numbers because they distribute values more evenly and avoid repeating patterns.
  • Music theorythe mathematics of which musical intervals sound "pure" versus dissonant traces back to small-prime frequency ratios.

Why 1 does not count as prime

It can seem arbitrary that 1 is excluded from the primes, but the reason is exactly the uniqueness property above. If 1 were allowed to count as a prime factor, then 12 could be written as 2² × 3, or equally as 1 × 2² × 3, or 1³ × 2² × 3, and so on forever — the factorization would stop being unique. Excluding 1 is what keeps "the" prime factorization of a number well defined, rather than one of infinitely many equally valid answers.

What this assumes, and where it stops

Assumptions

  • The input is a whole number of at least 2.

Limitations

  • Exact only up to about 9 quadrillion, the limit of exact integer arithmetic in JavaScript.
  • Trial division slows for large numbers whose smallest prime factor is itself large — a semiprime of two 8-digit primes will be noticeably slower than a highly composite number of the same size.

Common questions

What is prime factorisation used for?

Simplifying fractions, finding GCFs and LCMs, and solving problems involving divisibility. Beyond school mathematics, the fact that factorising very large numbers is computationally hard is precisely what makes RSA public-key cryptography secure.

Why is 1 not a prime number?

Because including it would break the uniqueness of prime factorisation. If 1 counted as prime, then 12 could be written as 2² × 3, or 1 × 2² × 3, or 1² × 2² × 3, and so on indefinitely. Excluding 1 keeps every number’s factorisation unique.

Formula and content last reviewed on .

Results are estimates for information only, not professional advice.

Report an error

Tools people commonly use alongside the prime factorization calculator.

See all math calculators →