How to find the prime factors of a number
A prime number has exactly two divisors: 1 and itself. 2, 3, 5, 7 and 11 are prime; 1 is not, because it only has one divisor. Every whole number greater than 1 is either prime or can be written as a product of primes in exactly one way, apart from the order the primes are listed in. This is called the fundamental theorem of arithmetic. Finding that product is prime factorization — sometimes spelled prime factorisation. Type a whole number into the box above and the calculator breaks it down, showing every division step, the number written out in full, whether it is prime, and how many divisors it has.
What to type in
Enter any whole number from 1 up to 9,007,199,254,740,991 — that is nine quadrillion, and it is the largest integer a web browser can store without losing digits. A number with a decimal point is accepted only if the part after the point is zero, so 12.0 is read as 12, but 12.5 is rejected, because prime factorization only applies to whole numbers. Negative numbers, 0 and 1 are all accepted; the result explains why each one is a special case rather than showing a normal factorization. The three preset buttons above the form fill in 360, 1024 and 9973 so you can see a typical result, a pure power of one prime, and a prime number without typing anything.
How the calculator finds the factors
The method is trial division: try dividing the number by small primes, and whenever one divides in exactly, divide it out and try again on what is left. The calculator does this in a fixed order. It divides out every 2 first, then every 3. After that, every prime is one more or one less than a multiple of 6, so it only has to test numbers of the form 6k − 1 and 6k + 1 — for example 5, 7, 11, 13, 17, 19 and so on — skipping the even numbers and multiples of 3 in between. Testing stops as soon as the candidate divisor, squared, is larger than what remains to be factored: if nothing up to the square root of a number divides it, the number itself must be prime, because any factor larger than its square root would have to pair with one smaller than it. That is also why a number like 9973 is confirmed prime without checking anywhere near 9973 divisors — only numbers up to about 100 need testing, since 100² is just over 9973.
Worked examples
360
- 360 is even, so divide by 2: 360 ÷ 2 = 180.
- 180 ÷ 2 = 90, and 90 ÷ 2 = 45. 45 is odd, so 2 no longer divides it.
- 45 ÷ 3 = 15, and 15 ÷ 3 = 5.
- 5 is prime: 5 ÷ 5 = 1, and the process stops.
The primes used were 2, 2, 2, 3, 3 and 5, so 360 = 2³ × 3² × 5. The calculator’s step table is the same ladder of divisions, one row per division. 360 has 24 divisors — worked out below — and 4 distinct prime factors: 2, 3 and 5, counting each prime once no matter how many times it appears.
1024
1024 is a power of two: dividing by 2 repeatedly gives 512, 256, 128, 64, 32, 16, 8, 4, 2, 1 — ten divisions in total, all by the same prime. The result is 1024 = 2¹⁰, with only one distinct prime factor and 11 divisors (1, 2, 4, 8, 16, 32, 64, 128, 256, 512 and 1024).
9973
No prime up to 100 divides 9973 exactly, and 100² is already past 9973, so the calculator stops and reports it as prime. The result is simply 9973, with one division step (dividing by itself), 2 divisors (1 and 9973), and the “Prime number?” field set to yes.
9,007,199,254,740,991 — the input limit
Typed at the calculator’s exact maximum, this factors as 6,361 × 69,431 × 20,394,401 — three distinct primes, each appearing once, giving (1 + 1)³ = 8 divisors. It shows that even the largest number the tool accepts still resolves in a handful of steps, because none of its prime factors happen to be large.
Reading the result
The main answer is shown in exponent form, such as 2³ × 3² × 5, where the small raised number is the exponent — it means that prime is multiplied by itself that many times. Below it, “Written out” lists the same primes one at a time without exponents, for numbers small enough to display in full. “Prime number?” answers yes or no. “Number of positive divisors” counts every whole number that divides the input exactly, including 1 and the number itself; it is worked out by adding 1 to each exponent and multiplying the results together — for 360 that is (3 + 1) × (2 + 1) × (1 + 1) = 24. “Distinct prime factors” counts how many different primes appear, ignoring how many times each one repeats. When there are 120 or fewer divisors, the full list is shown as well; above that the list is left out and only the count is given, since a list running into the hundreds or thousands would not fit usefully on the page.
What prime factors are used for
- Greatest common divisor: multiply the primes two numbers share, each to the lower power. The GCD and LCM calculator does this directly.
- Least common multiple: multiply every prime that appears, each to the higher power.
- Simplifying fractions: cancel primes that appear in both the top and bottom of a fraction.
- Simplifying square roots: pull pairs of a repeated prime outside the root — since 360 = 2³ × 3² × 5, one pair of 2s and the pair of 3s come out, leaving √360 = 6√10.
- Counting divisors: add 1 to each exponent and multiply, as shown above for 360.
0, 1, negative numbers and decimals
1 has no prime factors: it is neither prime nor composite, and its factorization is what mathematicians call the empty product. 0 has no prime factorization either, for a different reason — every prime number divides 0 exactly, so there is no unique way to write it as a product of primes. A negative number is written as −1 times the factorization of its absolute value, for example −12 = −1 × 2² × 3; −1 is called a unit, not a prime, and its only job is to carry the sign. Decimals such as 2.5 are not whole numbers, so prime factorization does not apply to them at all, and the calculator asks for a whole number instead of guessing what was meant.
Common mistakes
- Treating 1 as prime. It is not — a prime needs exactly two divisors, and 1 only has one.
- Forgetting the exponent means repetition, not a separate factor. 2³ is 2 used three times (2 × 2 × 2 = 8), not the number 2 written next to a 3.
- Missing repeated primes when counting distinct factors. 1024 = 2¹⁰ has ten divisions but only one distinct prime factor, 2.
- Assuming a big number always takes a long time. 9,007,199,254,740,991 factors in three steps because its prime factors are relatively small; a much smaller number that happens to be prime, or the product of two large primes, needs every candidate up to its square root checked.
Limitations
The calculator only accepts whole numbers up to 9,007,199,254,740,991. Beyond that, numbers cannot be stored exactly in a browser, so a result would risk being wrong without any obvious sign of it — the input is refused instead. Trial division is a simple, reliable method, but it is not the fastest way to factor numbers that are the product of two very large primes; those cases take the longest to resolve, even within the accepted range.
Frequently asked questions
What is prime factorization?
Writing a whole number as a product of prime numbers. For example, 360 = 2 × 2 × 2 × 3 × 3 × 5, usually written 2³ × 3² × 5. Every whole number greater than 1 has exactly one prime factorization, apart from the order of the factors.
How do you find the prime factors of a number?
Divide by the smallest prime that goes in exactly, write down that prime, and repeat with the quotient. When the quotient is 1, the primes you wrote down are the factorization. The calculator shows each of these divisions.
What is the prime factorization of 1?
1 has no prime factors. It is neither prime nor composite, and its factorization is the empty product. The calculator says this rather than showing an error.
Can 0 be factorized?
No. Every prime divides 0, so 0 cannot be written as a unique product of primes. The calculator explains this when you enter 0.
What about negative numbers?
A negative number is written as −1 times the factorization of its absolute value, for example −12 = −1 × 2² × 3. −1 is not a prime; it is included only to carry the sign.
Why are decimals rejected?
Prime factorization is defined for whole numbers. A number such as 12.5 has no prime factorization in this sense, so the calculator asks for a whole number. A value like 12.0 is accepted as 12.
How is the number of divisors worked out?
Add 1 to each exponent and multiply the results. For 360 = 2³ × 3² × 5, that is (3 + 1) × (2 + 1) × (1 + 1) = 24 divisors.
How large a number can it factorize?
Whole numbers up to 9,007,199,254,740,991, the largest integer a browser can store exactly. Larger values would lose digits, so they are refused instead of giving a wrong answer.
Why does a big prime number take longer than a number like 1024?
The calculator only stops trying divisors once it finds one, or once it has checked every candidate up to the square root of the number. 1024 is caught after one divisor (2), so it finishes almost instantly. A large prime, or a number that is the product of two large primes, has no small divisor, so every candidate up to the square root has to be tried before the tool can conclude it is prime.
Why is the full divisor list sometimes missing from the result?
The calculator only lists every divisor when there are 120 or fewer of them. Highly composite numbers can have far more divisors than that, and a list of thousands of numbers would not be useful on the page, so it is left out and the divisor count is shown instead.