Prime Factorization Calculator

Enter a whole number from 1 to 9,007,199,254,740,991. The result shows its prime factorization, whether it is prime, and every number that divides it.

A whole number from 1 to 9,007,199,254,740,991 (2^53 − 1).

Prime factorization

360 = 2^3 × 3^2 × 5

Prime or composite

Composite

Distinct prime factors

3

Number of divisors

24

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

How it works

Every whole number greater than 1 is either prime (its only divisors are 1 and itself) or can be written as a product of primes in exactly one way, apart from the order of the factors. That product is its prime factorization, written here in exponent form: 360 = 2^3 × 3^2 × 5.

The calculator finds it by trial division: it divides out 2 as many times as possible, then 3, then every number of the form 6k ± 1 up to the square root of what is left. Anything that survives above the square root is itself prime. Because the search stops at the square root, even the largest allowed number, just under 2^53, is factored in about a second on a desktop, longer on a phone.

The exponents give the number of divisors without listing them: add 1 to each exponent and multiply. For 360 that is (3 + 1)(2 + 1)(1 + 1) = 24. The divisors themselves are every product of the primes raised to powers from 0 up to each exponent.

Formula

n = p₁^e₁ × p₂^e₂ × … × pₖ^eₖ      (unique, primes ascending)
τ(n) = (e₁ + 1)(e₂ + 1) … (eₖ + 1)   (number of divisors)
n is prime  ⇔  τ(n) = 2

Example

360 = 2^3 × 3^2 × 5. It is composite with three distinct prime factors, and its divisor count is (3 + 1)(2 + 1)(1 + 1) = 24: 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 18, 20, 24, 30, 36, 40, 45, 60, 72, 90, 120, 180 and 360.

1,001 = 7 × 11 × 13 and has (1 + 1)(1 + 1)(1 + 1) = 8 divisors. 97 has no divisor between 2 and 9 (its square root is under 10), so it is prime with exactly 2 divisors, 1 and 97.

Assumptions and limitations

  • The input must be a whole number from 1 to 9,007,199,254,740,991 (2^53 − 1), the largest integer JavaScript represents exactly. Larger values would be rounded before they could be factored.
  • 1 is neither prime nor composite; it has no prime factors and exactly one divisor, itself.
  • The divisor list is written out for numbers with up to 1,000 divisors. Above that only the count is shown.
  • Negative numbers and decimals are rejected rather than rounded or made positive.

Frequently asked questions

Is 1 a prime number?

No. A prime has exactly two divisors, 1 and itself, and 1 has only one. Excluding 1 is what makes prime factorizations unique: otherwise 6 could be 2 × 3, or 1 × 2 × 3, or 1 × 1 × 2 × 3.

How can I tell quickly whether a number is prime?

Check whether any prime up to its square root divides it. For 97 the square root is just under 10, so only 2, 3, 5 and 7 need testing, and none divides it. This calculator does the same test for any number up to 2^53 − 1.