Prime Factorization Calculator

Break a whole number into its prime factors and count its divisors.

Math and PercentUpdated 2026-11-203 min read
Prime Factorization Calculator
Enter an integer from 2 to 1,000,000,000.
Prime factorization
...
Distinct primes...
Prime factors with repeats...
Positive divisors...

What it does

Prime factorization is the task of writing a whole number as a product of prime numbers. The fundamental theorem of arithmetic says that this product is unique apart from the order of the terms. That means 360 can be written as two cubed times three squared times five, and no other set of primes will ever multiply to 360.

The tool uses trial division. It starts with the smallest prime, repeatedly divides it out of the number, and records how many times it worked. It then moves to the next candidate and repeats. Once the remaining value has no divisor up to its own square root, whatever is left must be prime and is added as the final factor.

The square root shortcut is what makes the search manageable. If a number is composite, at least one of its prime factors is no larger than its square root, so there is no need to test candidates beyond that point. The tool also has an iteration guard so even hostile inputs terminate promptly.

Exponents are shown with superscript digits, and factors are joined with a multiplication sign. A number that is itself prime simply appears as a single factor. The tool also prints three counts: how many different primes appear, how many prime factors there are when repeats are counted, and how many positive divisors the number has.

Divisor count follows from the exponents. If the factorization is p to the power a times q to the power b, the number of divisors is a plus one times b plus one, because each prime may appear zero through a times in a divisor. This works for any size of number once the exponents are known.

How to use

  1. Enter a whole number between 2 and 1,000,000,000.
  2. Read the factorization, with exponents shown as superscript digits.
  3. Check the count of distinct primes against the number of terms in the factorization.
  4. Use the total factor count when you need to know how many primes are counted with repeats.
  5. Read the divisor count for the total number of positive divisors.
  6. Try a prime such as 97 to see that the factorization has a single term.

Formula

n = p1^a1 x p2^a2 x ... x pk^ak. Number of divisors = (a1 + 1) x (a2 + 1) x ... x (ak + 1).
n
The whole number being factored, greater than one.
pi
The ith distinct prime factor.
ai
The exponent of the ith prime, counted by repeated division.
k
The number of distinct prime factors.

Trial division only tests candidates whose square is at most the remaining value, which is enough to decide whether that value is prime. The number one is a unit and is neither prime nor composite, so it has no prime factorization and the tool rejects it. Inputs must be whole numbers, so a decimal entry returns an error.

Worked example

Example: factor 360

Default input: n = 360.

  1. Divide by 2 repeatedly: 360 / 2 = 180, / 2 = 90, / 2 = 45. That gives 2³.
  2. Move to 3: 45 / 3 = 15, / 3 = 5. That gives 3².
  3. The remainder is 5, which is prime, so it is added as 5¹.
  4. The factorization is 2³ × 3² × 5, or 2³ × 3² × 5 with the exponent 1 omitted.
  5. Divisor count: (3 + 1) x (2 + 1) x (1 + 1) = 4 x 3 x 2 = 24.
  6. The tool shows 2³ × 3² × 5, distinct primes 3, total factors 6 and divisors 24.

Reference table

Factorizations and divisor counts for small numbers
NumberPrime factorizationPositive divisors
122² × 36
362² × 3²9
602² × 3 × 512
1002² × 5²9
3602³ × 3² × 524

Limits

  • Accepts whole numbers only, between 2 and 1,000,000,000.
  • Uses trial division, which is simple and predictable but not the fastest method for very large integers.
  • Reports positive divisors only, not signed divisors.
  • Does not draw a factor tree or list the individual divisors.

Common mistakes

  • Entering a decimal or a negative number into an integer only field.
  • Counting an exponent of one as if it added two prime factors.
  • Assuming a number with few digits must have few divisors.
  • Forgetting that a prime number appears as a single factor in the output.
  • Multiplying the exponents instead of adding one to each before multiplying.

Try it yourself

Quick checks. Answers sit tucked under each question.

Factor 840 with the tool. What does it show?

840 = 2³ × 3 × 5 × 7. The tool shows 4 distinct primes, 6 prime factors when repeats are counted and 32 positive divisors.

What does the tool show for the prime 17?

The factorization is 17, with 1 distinct prime, 1 total factor and 2 positive divisors.

What happens if you enter 1?

The tool returns the error Enter a whole number between 2 and 1,000,000,000, because one is a unit with no prime factorization.

Questions

What is a prime number?

An integer greater than one whose only positive divisors are one and itself. Two, three, five and seven are the first few primes.

Why is the factorization unique?

The fundamental theorem of arithmetic states that every integer greater than one has exactly one prime factorization, apart from the order of the factors.

Why stop testing at the square root?

If a number has a factor larger than its square root, the matching factor paired with it must be smaller than the square root, so that smaller one would have been found first.

How is the divisor count calculated?

Add one to each exponent in the factorization and multiply the results. Each prime may appear from zero up to its exponent times in a divisor.

Is 1 a prime number?

No. It is a unit, and allowing it as a prime would break the uniqueness of factorization.

What is the largest number this tool accepts?

One billion. Larger inputs are rejected so the trial division stays quick and predictable.

Sources

How this page was checked. The formula above was matched against the cited sources, and the worked example was run through the tool on this page before publishing. If you spot an error, contact us so we can fix it and note the correction.