Skip to main content

Prime Factorization Calculator - Factor a Whole Number

Break a positive integer into primes and write it as a product of powers such as 2^3 × 5 × 7. Trial division runs in your browser, up to 15 digits.

Integer to Factor

n must be an integer ≥ 2, at most 15 digits. Zero, one, negatives, and decimals are rejected. Factorization updates as you type. A 15-digit prime can take a few seconds because trial division walks up to √n.

Prime Factorization

The prime-power factorization will appear here

What Is a Prime Factorization Calculator and Why Do You Need One?

A prime factorization calculator takes a whole number greater than 1 and writes it as a product of primes, usually in canonical order with exponents: 2a × 3b × 5c × …. That product is unique up to the order of the factors. The statement is the fundamental theorem of arithmetic: every integer n ≥ 2 has exactly one such factorization.

Factoring by hand is easy for 84 or 360 and tedious for a ten-digit composite whose smallest prime factor sits near the square root. This page automates the same method you would use on paper - trial division - not a cryptographic factoring engine. It peels off 2, then tries odd candidates 3, 5, 7, … until the remaining cofactor is 1 or prime. The algorithm is exact. It is also slow when n is large and prime, because √n for a 15-digit integer is about 3×107 odd steps in the worst case.

This free online factoring tool runs entirely in your browser. The number never leaves the device. Inputs are capped at 15 digits on purpose: beyond that, naive trial division is the wrong tool, and claiming to factor a 50-digit RSA modulus in a web page would be dishonest. For greatest common divisors of two already-factored (or small) integers, use the common factor calculator. For exact arithmetic on integers that are far too big to factor here, use the big number calculator.

How to Use This Free Online Prime Factorization Calculator

Using this integer factoring tool is a single-field workflow:

  1. Type a positive integer greater than 1. Commas in 1,234,567 are stripped. Decimals such as 12.0, scientific notation, zero, one, and negative values are rejected.
  2. Watch the right panel. Factorization updates as you type. A small composite such as 840 is instant. A 15-digit prime may pause the tab for a short while because the loop runs up to √n.
  3. Read the canonical string (for example 2^3 × 3 × 5 × 7), the list of prime powers, the expanded factor list, and the product check that multiplies the powers back to n.
  4. If n itself is prime, the canonical form is just n, isPrime is true, and the factor list is a single copy of n. Copy the canonical string, or clear the field to start over. The last input is saved locally for up to 30 days.

Limit: at most 15 digits. This is not Pollard rho, the quadratic sieve, or the number-field sieve. Those methods factor cryptographic moduli; this page does homework and modest integers exactly, with an algorithm you can follow on paper.

Trial Division - How Prime Factorization Works

n = p1e1 × p2e2 × …
pi prime, ei ≥ 1, p1 < p2 < …

The calculator’s loop is the same as the paper method:

  1. While n is even, divide by 2 and count the exponent of 2.
  2. Set d = 3. While d × d ≤ n, test whether d divides n. If it does, divide it out completely and record the exponent.
  3. Increase d by 2 (skip even candidates after 2).
  4. If a cofactor greater than 1 remains, that cofactor is prime - it had no divisor up to its square root.

Stopping at √n is enough: if n had two prime factors both larger than √n, their product would exceed n. Wheel factorization (skipping multiples of 3 and 5 as well) would be faster; this implementation stays on the odd-integer trail so the steps match a typical algebra class.

Example - 840:

  • 840 ÷ 2 = 420, 210, 105 → three factors of 2
  • 105 ÷ 3 = 35 → one factor of 3
  • 35 ÷ 5 = 7 → one factor of 5
  • 7 is prime (√7 < 3 already passed)
  • 23 × 3 × 5 × 7
  • Product check: 8 × 3 × 5 × 7 = 840

Example - 97 (prime):

  • Odd, so no factor 2
  • Odd d from 3 up to √97 ≈ 9.8: 3, 5, 7, 9. None divide 97
  • Leftover 97 is prime. Canonical form is just 97. isPrime is true.

Example - 100 = 22 × 52:

  • Two factors of 2 leave 25
  • 25 = 5 × 5, so 52
  • Written 2^2 × 5^2, not 2 × 2 × 5 × 5, although the expanded list shows the repeated primes

Example - 1 is rejected:

The empty product of primes equals 1 by convention, but 1 is not prime and is not a product of one or more primes in the sense used here. The error message is 1 is not a product of primes.

Prime, Composite, and 1 - How the Labels Differ

KindDefinitionCanonical formThis calculator
PrimeExactly two distinct positive divisors: 1 and itselfn itselfisPrime true; n ≥ 2
CompositeProduct of at least two primes (counting multiplicity)2^a × 3^b × …isPrime false
1Neither prime nor compositeEmpty productRejected
0 and negativesUnique factorization is stated for n ≥ 2-Rejected

Powers of a single prime, such as 8 = 23 or 49 = 72, are composite even though only one prime appears. isPrime is true only when there is a single prime with exponent 1. 4, 9, 25, and 49 are therefore composite here, which matches the usual definition.

Uniqueness, GCD, and Why Canonical Form Matters

Once you have n = 2a × 3b × 5c and m = 2a′ × 3b′ × 5c′, the greatest common divisor is 2min(a,a′) × 3min(b,b′) × … and the least common multiple uses the max of each exponent. That is why algebra courses insist on writing factors in rising prime order with exponents rather than a jumble such as 7 × 2 × 2 × 3 × 2.

Simplifying a fraction is the same idea: cancel the min exponent of each prime that appears in both numerator and denominator. 840/70 = (23 × 3 × 5 × 7) / (2 × 5 × 7) = 22 × 3 = 12. For two integers whose GCD you want without listing every prime, the Euclidean algorithm on the common factor calculator is faster than factoring both sides - especially when the numbers have large prime factors.

Canonical form also makes equality obvious. 23 × 5 and 5 × 8 are the same integer 40, but only the first is the prime-power writing this tool copies. Homework graders usually want that form, not an expanded 2 × 2 × 2 × 5, though both are listed so you can check either style.

Where Prime Factorization Shows Up in Real Work

1. Fractions, ratios, and unit conversions

Canceling common prime factors is how you reduce 84/120 to 7/10 without guessing. The same cancellation appears when you convert units that are products of integer conversions (inches, seconds, bits).

2. LCM of cycle lengths and schedules

If one event repeats every 12 minutes and another every 18, the first common time is LCM(12, 18) = 22 × 32 = 36. Factorization is one way to see the LCM; the Euclidean algorithm plus |ab|/gcd(a,b) is another.

3. Teaching cryptography - with an honest limit

RSA security rests on the hardness of factoring a product of two large primes. A classroom modulus such as 91 = 7 × 13 factors instantly here. A 15-digit semiprime whose factors are both near √n will make trial division work, but slowly. A 2048-bit RSA modulus will not factor on this page, and the 15-digit cap exists so the tool does not pretend otherwise. If you only need to multiply two large primes together, that product belongs on the big number calculator, not here.

4. Checking perfect squares and square-free integers

n is a perfect square exactly when every exponent in its factorization is even. n is square-free when every exponent is 1. Those tests are immediate once the canonical string is on screen.

Why Trial Division Stops at 15 Digits

Complexity is roughly O(√n) divisions in the worst case (n prime, or n a product of two primes of similar size). For n = 106, √n is 1,000 - instant. For n = 1012, √n is a million - still fine in JavaScript. For n = 1015 − a 15-digit prime - √n is about 3.16 × 107. Walking odd integers up to that bound is on the order of 107 BigInt remainder operations. That can take a noticeable moment in the browser, which is why the helper text warns you. At 16 digits, √n is about 108, and a naive loop starts to feel like a hang.

Faster algorithms exist. Pollard’s rho often finds a small factor in far fewer steps. The quadratic sieve and the general number-field sieve factor integers with tens or hundreds of digits on serious hardware. None of those are implemented here. Shipping a half-finished rho loop and calling it a “crypto factorizer” would be misleading. Trial division is transparent, matches the school method, and is reliable up to the 15-digit line we drew.

Highly composite numbers with only small prime factors finish immediately even at 15 digits, because each division shrinks n and the loop’s √n bound drops. The slow case is specifically “large and prime-ish.” That is a property of the algorithm, not a bug in the page.

Frequently Asked Questions (FAQ) - Prime Factorization

How do I factor a number into primes?

Divide the integer by the smallest prime that goes in evenly, repeat with the quotient, and keep going until the remaining factor is 1 or prime. This calculator does that trial division and writes the result as a product of prime powers.

What does 2^3 × 5 mean in prime factorization?

It is the canonical product of primes: three factors of 2 and one factor of 5, so 8 × 5 = 40. Every integer greater than 1 has a unique factorization of this form (order of primes aside).

What is the largest number this prime factorization calculator can handle?

Positive integers up to 15 digits. Trial division is simple and exact, but it becomes too slow for larger composites, especially when they have a large prime factor near the square root.

How does trial division find prime factors?

It tests 2, then 3, 5, 7, … up to sqrt(n). Each time a divisor d divides n, n is replaced by n/d and the exponent of d is increased. Whatever is left after the loop is either 1 or a prime.

Is 1 a prime factor of every number?

No. By definition 1 is not a prime, so it never appears in a prime factorization. The number 1 itself has an empty product of primes and is not factored here.

Does this prime factorization calculator upload my number?

No. Factorization runs in your browser with JavaScript. Nothing is sent to a server. After the page loads, the tool still works if the network drops.

Why Choose Our Prime Factorization Calculator?

  • Free, no account. Unlimited factorizations within the 15-digit cap.
  • Private. Trial division stays in the browser.
  • Canonical 2^a × 3^b × … form plus an expanded factor list.
  • Product check so you can see the powers multiply back to n.
  • Honest limits - trial division, 15 digits, not a cryptographic factoring service.
  • Works offline after the first page load.