Advertisement
728x90 or 970x250 Ad Space

Prime Factorization Calculator

Enter a whole number to see its prime factorization in expanded form and with exponents, along with a step-by-step factor tree.

Prime Factorization Calculator

Result

Number -
Prime Factors -
As Exponents -
Factor Tree -
Advertisement
300x250 or 320x100 Ad Space

What Makes a Number Prime

prime numbers highlighted among the positive integers

A prime number is a whole number greater than 1 whose only positive divisors are 1 and itself. Seven is prime because nothing except 1 and 7 divides it evenly. Eight is not, because 2 and 4 also divide it. The first few primes are 2, 3, 5, 7, 11, 13, 17, 19, 23, and 29.

Two numbers sit outside the classification. The number 1 has only one positive divisor, so it is neither prime nor composite; it is called a unit. The number 0 is divisible by every positive integer, so it cannot satisfy the definition either. Negative numbers are not prime in the usual sense, because divisibility is normally discussed for positive integers.

A composite number is any whole number greater than 1 that is not prime. It can be written as a product of two smaller whole numbers greater than 1. That is the whole distinction: primes cannot be split that way, composites can. The number 2 is the only even prime, since every larger even number is divisible by 2.

Primality is not the same as being odd. Nine is odd and composite. Two is even and prime. A number ending in 5 is composite once it is larger than 5, because 5 divides it. These shortcuts catch many cases but none of them replaces the definition.

The primes are irregularly spaced. There are long gaps and clusters, and no simple formula produces them all. That irregularity is what makes them useful in cryptography and what keeps them interesting to mathematicians after more than two thousand years.

Prime Factorization and Uniqueness

a composite number broken into its prime factors

Prime factorization writes a composite number as a product of primes. For example, 60 equals 2 × 2 × 3 × 5, usually written 2² × 3 × 5. The factors are all prime, and multiplying them returns the original number. The same idea is called prime decomposition.

The fundamental theorem of arithmetic says that every integer greater than 1 has exactly one prime factorization, apart from the order in which the factors are written. That uniqueness is what makes the factorization a reliable fingerprint of a number. It also means two different-looking factor trees must end at the same multiset of primes.

Factorization is closely tied to two other operations. The greatest common divisor of two numbers takes the smallest exponent of each shared prime; the least common multiple takes the largest exponent of every prime that appears. For 12 = 2² × 3 and 18 = 2 × 3², the GCD is 2 × 3 = 6 and the LCM is 2² × 3² = 36. Those relationships are why factoring is taught alongside fractions and common denominators.

Several algorithms exist. Trial division is the simplest: test small primes in order. Pollard's rho and the quadratic sieve are faster for larger inputs, and the general number field sieve is the best known classical method for very large numbers. Each is a different trade between simplicity and speed.

No efficient classical algorithm is known for factoring a large integer that is the product of two large primes. That is not the same as saying no algorithm exists; algorithms exist, and they work, but their running time grows so quickly with the size of the number that a well-chosen 2048-bit product is beyond practical reach. This asymmetry between easy multiplication and hard factoring is the basis of RSA and several other cryptosystems.

Trial Division, Step by Step

trial division of 820 by its smallest prime factors

Trial division means dividing the number by candidate primes, smallest first, until the remaining quotient is prime. You do not need to test every integer, and you do not need to test any prime larger than the square root of the number you are factoring. If a number has a factor larger than its square root, it must also have a matching factor smaller than the square root.

Take 820. It is even, so divide by 2: 820 ÷ 2 = 410. Still even, so divide by 2 again: 410 ÷ 2 = 205. Now test 3: the digit sum of 205 is 7, which is not a multiple of 3, so 3 does not divide it. Test 5: 205 ends in 5, so 205 ÷ 5 = 41. The square root of 41 is about 6.4, and no prime up to that limit divides it, so 41 is prime. The factorization is 2² × 5 × 41.

Step Division Why it works
1820 ÷ 2 = 410820 is even
2410 ÷ 2 = 205410 is still even
3205 ÷ 5 = 41Ends in 5; 3 does not divide it
441 is primeNo prime up to √41 divides it

The stopping rule is the part people miss. Once the quotient is prime, stop. Once you have tested every prime up to the square root of the current quotient, the quotient itself is prime. Continuing beyond that point wastes time and invites arithmetic slips.

Trial division is slow for large inputs. For a number near 1012, the square root is 106, so a naive search may test hundreds of thousands of candidates. The calculator handles its ten-digit limit comfortably, but the same method applied to a 200-digit semiprime would take far longer than the age of the universe.

Factor Trees

factor tree for 820 ending in prime factors

A factor tree is a visual way to organize the same search. Start with any factor pair of the number, draw branches to each factor, and repeat until every branch ends at a prime. The tree is not unique: 820 can be split as 82 × 10 or 20 × 41, and the branches will look different. The final collection of primes is the same.

Using the first split, 820 = 82 × 10. Then 82 = 2 × 41 and 10 = 2 × 5. The leaves are 2, 41, 2, and 5, which regroup as 2² × 5 × 41. Using 20 × 41 instead gives 20 = 2² × 5 and a leaf of 41, with the same result. The freedom to choose an easy pair is what makes the tree convenient by hand.

The tree is a teaching device, not a proof of uniqueness. Uniqueness comes from the fundamental theorem, not from the shape of the diagram. Two students can draw completely different trees for 360 and both be right, because the multiset of prime leaves is what matters.

For a computer, a tree is just recursion. Split the number, recurse on each composite branch, and collect the primes. Trial division is usually simpler to implement and faster for the sizes this calculator handles, which is why the result panel shows the factorization directly and the tree as a formatted string rather than as a drawn diagram.

The difficulty of factoring is what makes the tree metaphor stop being cute at scale. A 232-digit number has no manageable tree. In 2009, a distributed effort involving hundreds of machines factored RSA-768, a 232-digit semiprime, after roughly two years of computation. That result was a research milestone, not something a desktop tool can repeat.

Common Numbers

prime factorizations listed for common composite numbers

The table lists the prime factorization of every integer from 1 to 100, followed by several round numbers. A dash marks 1, which has no prime factorization. The word prime marks a number that is already prime and therefore needs no further breakdown.

Number Prime factorization Number Prime factorization
1—2prime
3prime422
5prime62 × 3
7prime823
932102 × 5
11prime1222 × 3
13prime142 × 7
153 × 51624
17prime182 × 32
19prime2022 × 5
213 × 7222 × 11
23prime2423 × 3
2552262 × 13
27332822 × 7
29prime302 × 3 × 5
31prime3225
333 × 11342 × 17
355 × 73622 × 32
37prime382 × 19
393 × 134023 × 5
41prime422 × 3 × 7
43prime4422 × 11
4532 × 5462 × 23
47prime4824 × 3
4972502 × 52
513 × 175222 × 13
53prime542 × 33
555 × 115623 × 7
573 × 19582 × 29
59prime6022 × 3 × 5
61prime622 × 31
6332 × 76426
655 × 13662 × 3 × 11
67prime6822 × 17
693 × 23702 × 5 × 7
71prime7223 × 32
73prime742 × 37
753 × 527622 × 19
777 × 11782 × 3 × 13
79prime8024 × 5
8134822 × 41
83prime8422 × 3 × 7
855 × 17862 × 43
873 × 298823 × 11
89prime902 × 32 × 5
917 × 139222 × 23
933 × 31942 × 47
955 × 199625 × 3
97prime982 × 72
9932 × 1110022 × 52

The patterns are worth noticing. Powers of 2 produce a single prime with a rising exponent. Multiples of 10 always contain both 2 and 5. A number like 72 = 2³ × 3² shows how the exponents record repeated division rather than repeated addition.

Number Prime factorization Number Prime factorization
20023 × 5230022 × 3 × 52
40024 × 5250022 × 53
60023 × 3 × 5270022 × 52 × 7
80025 × 5290022 × 32 × 52
100023 × 53

Use the table as a check, not as a substitute for the method. If your hand calculation disagrees with a row, multiply the factors back out before assuming the table is wrong; the more common error is a missed exponent or a factor that was never prime.

Using the Calculator

Type a whole number from 1 to 9,999,999,999 into the input field. The result updates as you type, showing the original number, the expanded product, the exponential form, and a factor tree string. A prime input is labeled as prime rather than being given a trivial factorization.

The calculator rejects zero, negative numbers, and values above the limit with an error message. A decimal entry is truncated to its whole-number part, so enter integers only. For 1 it reports that the number is neither prime nor composite. The Clear button resets the field and the results; editing the input recalculates immediately, so there is no separate submit step.

Read the expanded form and the exponential form together. The expanded form is easier to check by multiplication; the exponential form is easier to read when a prime repeats. The factor tree string shows the order in which the calculator split the number, which is useful for following the algorithm but is not the only valid tree.

The ten-digit limit is a deliberate trade. Factoring a number near the limit by trial division requires testing primes up to about 100,000, which is manageable in a browser. Raising the limit would make some inputs slow or unresponsive, particularly when the number is a product of two large primes near the square root.

Where Prime Numbers Show Up

Public-key cryptography. RSA depends on the gap between multiplying two large primes and factoring their product. Generating a key is fast; recovering the primes from the public modulus is believed to be impractical at current key sizes. Prime numbers also appear in Diffie-Hellman key exchange and in elliptic-curve constructions, though the role they play differs.

Computing. Hash tables often use prime or coprime sizes to spread keys evenly, pseudo-random generators use prime moduli, and error-correcting codes work over finite fields whose sizes are prime powers. These uses rely on the arithmetic properties of primes, not on factoring a large number.

Engineering and design. Gear tooth counts that share few factors distribute wear more evenly, because the same teeth do not repeatedly meet. Similar reasoning appears in scheduling, where coprime cycle lengths avoid resonance, and in the design of experiments where balanced patterns are built from prime intervals.

Biology. Periodical cicadas emerge on 13- or 17-year cycles. One hypothesis is that a prime interval makes it harder for predators with shorter, non-matching cycles to synchronize with the emergence. The hypothesis is plausible and not fully settled; it is a good example of a mathematical pattern used to frame a biological question.

Teaching. Factorization connects multiplication, division, fractions, and divisibility. Simplifying 18/24 to 3/4 is a factorization problem in disguise, and finding a common denominator is an LCM problem built from prime factors. The arithmetic is elementary; the structure is not.

Security and limits. The same difficulty that protects RSA also shapes advice about key sizes. As factoring methods and computers improve, the size of a safe key grows. Post-quantum cryptography is partly a response to the possibility that a large quantum computer could factor integers efficiently using Shor's algorithm, which would break RSA as currently deployed.

Common Mistakes

Stopping before every factor is prime. Writing 72 = 8 × 9 is a correct multiplication but not a prime factorization. Continue with 8 = 2³ and 9 = 3², giving 72 = 2³ × 3². A factor tree is finished only when every leaf is prime.

Including 1. Writing 12 = 1 × 2 × 2 × 3 is not wrong arithmetic, but 1 is not prime and does not belong in a prime factorization. The conventional form is 2² × 3. Including 1 makes the factorization non-unique and defeats the purpose.

Miscounting exponents. Each division by the same prime raises the exponent by one. For 64, dividing by 2 six times gives 2⁶, not 2⁵ or 2⁷. Multiply back to check: 2⁶ = 64. For a number like 360, the count is 2³ × 3² × 5, and a quick multiplication confirms it.

Forgetting the leftover prime. After dividing out all primes up to the square root, a remainder greater than 1 is itself prime. In the 820 example, 41 is left over after removing 2 and 5, and 41 is prime. Ignoring it produces an incomplete factorization.

Treating a factor tree as unique. Different first splits produce different-looking trees, and that is fine. The test is whether the leaves multiply to the original number and whether every leaf is prime, not whether two diagrams match.

Divisibility Rules

Divisibility rules are shortcuts for deciding whether a small prime divides a number without doing the full division. They speed up trial division and reduce arithmetic errors. The rules below cover the primes most likely to appear in a hand calculation.

Divisor Test Example
2Last digit is even1,284 ends in 4, so it is divisible by 2
3Digit sum is divisible by 31 + 2 + 8 + 4 = 15, so 1,284 is divisible by 3
4Last two digits form a multiple of 41,284 ends in 84, and 84 = 4 × 21
5Last digit is 0 or 51,285 is divisible by 5
6Divisible by both 2 and 31,284 passes both tests
8Last three digits form a multiple of 81,288 ends in 288, and 288 = 8 × 36
9Digit sum is divisible by 91 + 2 + 8 + 4 = 15, which is not a multiple of 9
11Alternating digit sum is divisible by 111 − 2 + 8 − 4 = 3, so 1,284 is not divisible by 11

The rule for 7 is less compact: double the last digit and subtract that from the rest of the number. If the result is a multiple of 7, so was the original. For 203, double 3 to get 6, subtract from 20 to get 14, and 14 is a multiple of 7, so 203 = 7 × 29. Repeat the test on a large result if needed.

These rules identify candidates; they do not complete a factorization. After dividing by a prime, run the tests again on the quotient. A number can pass the rule for 3 several times, which is exactly how an exponent such as 3⁴ arises.

Special Families of Primes

Mersenne primes have the form 2n − 1, named after Marin Mersenne. Examples include 3 = 2² − 1, 7 = 2³ − 1, and 31 = 2⁵ − 1. Not every n produces a prime: 2⁴ − 1 = 15 is composite. Mersenne numbers have a dedicated primality test, the Lucas-Lehmer test, which is why record primes in the modern era have almost always been Mersenne primes. By 2024, 52 Mersenne primes had been discovered.

The largest known prime at the time of writing is 2136,279,841 − 1, announced in October 2024. It has 41,024,320 digits. The search is coordinated by the Great Internet Mersenne Prime Search, which distributes the testing across volunteers' computers.

Twin primes are pairs that differ by 2, such as (3, 5), (5, 7), (11, 13), and (17, 19). The twin prime conjecture says there are infinitely many such pairs; it remains unproven. The largest known pair, found in 2016, has 388,342 digits.

Sophie Germain primes are primes p for which 2p + 1 is also prime. Examples include 2, 3, 5, 11, 23, and 29. The associated number 2p + 1 is called a safe prime, a term that appears in some cryptographic constructions. The pair is named after Sophie Germain, who did foundational work on Fermat's Last Theorem.

Palindromic primes read the same forward and backward: 11, 101, 131, 151, 313, 727. They are recreational curiosities rather than a family with a single defining structure. Factorial primes are one more or one less than a factorial: 5 = 3! − 1, 7 = 3! + 1, 23 = 4! − 1, and 719 = 6! − 1. They are rare, and no one knows whether infinitely many exist.

A Short History

Euclid, writing around 300 BCE, proved that there are infinitely many primes. His argument is still taught: assume a finite list, multiply the listed primes and add 1, and the resulting number is either a new prime or has a prime factor not on the list. Either way the assumption fails.

Eratosthenes, in the third century BCE, described the sieve that bears his name. It finds all primes up to a limit by repeatedly crossing out multiples of each prime. The method is ancient and still the standard way to generate a list of small primes.

The seventeenth through nineteenth centuries brought Fermat's little theorem, Euler's totient function, and Gauss's conjectures about how primes thin out. The prime number theorem, which makes Gauss's estimate precise, was proved independently by Hadamard and de la Vallée Poussin in 1896. The Riemann hypothesis, formulated in 1859, remains the most famous open question about the distribution of primes and carries a Clay Millennium Prize.

The modern computational era added two threads. One is the search for larger primes, which has been organized through distributed projects such as GIMPS since 1996. The other is cryptography: RSA, published in 1977, turned the difficulty of factoring into a practical security mechanism. The 2009 factorization of RSA-768 showed both how far the methods had come and how far they still were from breaking current keys.

The history is not finished. Factoring algorithms improve, key sizes grow, and quantum computing raises the possibility of a different kind of attack. Prime numbers remain both a classical subject and a live engineering concern.

Summary

A prime is a whole number greater than 1 with no divisors other than 1 and itself. Every larger integer factors uniquely into primes, which is what makes factorization useful for simplifying fractions, finding GCDs and LCMs, and understanding the structure of numbers.

Trial division and factor trees are the two hand methods worth knowing. Trial division tests primes up to the square root and stops when the quotient is prime; a factor tree organizes the same search visually. The calculator automates both for inputs up to ten digits and shows the expanded form, the exponent form, and the tree.

The applications run from school arithmetic to public-key cryptography. The same property that makes primes useful in RSA, the difficulty of factoring a large semiprime, is what limits how far hand methods can go. Understanding the small cases is the right place to start.

Frequently Asked Questions

What is the smallest prime number?

2 is the smallest prime. It is also the only even prime, because every larger even number is divisible by 2. The number 1 is not prime, since it has only one positive divisor.

Is 1 a prime number?

No. A prime must be greater than 1 and have exactly two positive divisors. The number 1 has only one positive divisor, itself, so it is neither prime nor composite. Including 1 would also break the uniqueness of prime factorization.

How many prime numbers are there?

Infinitely many. Euclid proved this around 300 BCE by assuming a finite list, multiplying the listed primes and adding 1, and showing that the result must have a prime factor not on the list. The primes become sparser as numbers grow, but they never run out.

What is prime factorization used for?

It simplifies fractions, finds greatest common divisors and least common multiples, and reveals the structure of a number. In computing, the difficulty of factoring large semiprimes underpins RSA and related public-key cryptosystems.

What is the largest known prime number?

At the time of writing, the largest known prime is 2^136,279,841 − 1, announced in October 2024. It has 41,024,320 digits and is a Mersenne prime. Records change when a new Mersenne prime is verified.

Is 0 a prime number?

No. Zero is divisible by every positive integer, so it has infinitely many divisors and cannot satisfy the definition of a prime. It is also not composite.

What is the difference between prime and composite numbers?

A prime greater than 1 has exactly two positive divisors: 1 and itself. A composite greater than 1 has at least one additional divisor. For example, 7 is prime and 8 is composite because 2 and 4 divide it.

How do you find prime factors of a large number?

Start with the smallest primes and divide whenever possible, then test primes up to the square root of the remaining quotient. If a remainder greater than 1 survives, it is prime. For very large numbers, algorithms such as Pollard's rho or the number field sieve are used instead of hand trial division.

What is the fundamental theorem of arithmetic?

It states that every integer greater than 1 is either prime or can be written as a product of primes, and that the factorization is unique apart from the order of the factors. This is why a prime factorization is a reliable description of a number.

What are twin primes?

Twin primes are pairs of primes that differ by 2, such as 3 and 5, 11 and 13, or 17 and 19. The twin prime conjecture says there are infinitely many such pairs, but that remains unproven.

Why is 2 the only even prime?

Every even number greater than 2 is divisible by 2 as well as by 1 and itself, so it has at least three positive divisors and is composite. The number 2 has only 1 and 2 as divisors, so it is prime.

Can a negative number be prime?

In standard number theory, primes are defined among the positive integers greater than 1. Negative values are not called prime, although their absolute values may be. The calculator accepts only positive whole numbers.

What is a factor tree?

A factor tree is a diagram that splits a number into factor pairs repeatedly until every branch ends in a prime. Different first splits produce different trees, but the final multiset of primes is the same because prime factorization is unique.

What is the largest number this calculator accepts?

The limit is 9,999,999,999, a ten-digit number. Inputs above that, zero, and negative values are rejected with an error message. A decimal is truncated to its whole-number part, so enter integers only. The limit keeps trial division fast enough to run in a browser.

Advertisement
970x250 or 728x90 Ad Space