NOTACAL logo

Prime Factorization Calculator

Prime Factorization Calculator

Give us your feedback! Was this useful?

Introduction

Prime factorization is the process of decomposing a composite number into a product of its prime factors. Every integer greater than 1 can be expressed uniquely as a product of powers of prime numbers — this is the Fundamental Theorem of Arithmetic, one of the most important results in number theory. For example, the number 84 can be written as 2² × 3 × 7, meaning 2, 3, and 7 are the prime factors of 84, with 2 appearing twice.

Prime factorization is not just a theoretical exercise. It underpins modern cryptography, including the RSA encryption system that secures online transactions, email, and messaging. The security of RSA depends on the practical difficulty of factoring large composite numbers — while multiplying two large primes is easy, recovering the original primes from the product is extraordinarily hard for sufficiently large numbers. [niven-book]

Beyond cryptography, prime factorization is essential for simplifying fractions, finding greatest common factors and least common multiples, solving Diophantine equations, and understanding the distribution of prime numbers. The Factor Calculator finds all divisors of a number, while this calculator focuses specifically on the unique prime factorization with step-by-step division.

How to Use

Enter any integer greater than 1 in the calculator above. The calculator automatically performs trial division by testing each integer from 2 upward to determine which primes divide the number and how many times each appears in the factorization.

Example 1: Factor 84.

  • 84 ÷ 2 = 42 (2 divides 84)
  • 42 ÷ 2 = 21 (2 divides 42 again)
  • 21 ÷ 3 = 7 (3 divides 21)
  • 7 ÷ 7 = 1 (7 divides 7)
  • Result: 84 = 2² × 3 × 7

Example 2: Factor 360.

  • 360 ÷ 2 = 180 (2¹)
  • 180 ÷ 2 = 90 (2²)
  • 90 ÷ 2 = 45 (2³)
  • 45 ÷ 3 = 15 (3¹)
  • 15 ÷ 3 = 5 (3²)
  • 5 ÷ 5 = 1 (5¹)
  • Result: 360 = 2³ × 3² × 5

Example 3: Factor a large prime like 997.

  • Test divisibility by 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31 — none divide evenly
  • Since √997 ≈ 31.6, no further testing is needed
  • Result: 997 is prime (only factors are 1 and 997)

For finding all divisors (not just prime factors), use the Factor Calculator.

The Fundamental Theorem of Arithmetic

The Fundamental Theorem of Arithmetic states that every integer greater than 1 either is prime itself or can be represented as a unique product of primes, up to the order of the factors. This uniqueness is what makes prime factorization so powerful — every number has exactly one prime factorization, making it a canonical representation of that number.

n=p1e1×p2e2××pkekn = p_1^{e_1} \times p_2^{e_2} \times \cdots \times p_k^{e_k}
[mathworld-prime]

Where p₁, p₂, ..., pₖ are distinct prime numbers and e₁, e₂, ..., eₖ are positive integer exponents. The number 2,100, for example, factors as 2² × 3¹ × 5² × 7¹.

This theorem is not trivial. The ancient Greeks knew of it, but the first rigorous proof was given by Carl Friedrich Gauss in his 1801 work Disquisitiones Arithmeticae, which laid the foundation for modern number theory. The uniqueness of factorization does not hold in all number systems — for example, in the ring ℤ[√-5], the number 6 can be factored as both 2 × 3 and (1 + √-5)(1 - √-5), a discovery that led to the development of ideal theory by Ernst Kummer and Richard Dedekind. [niven-book]

Trial Division Algorithm

The most straightforward method for finding prime factors is trial division, which this calculator implements. The algorithm tests potential divisors in increasing order and records how many times each divides the number.

For i=2 to n: while nmodi=0: record i, set n=n/i\text{For } i = 2 \text{ to } \lfloor\sqrt{n}\rfloor: \text{ while } n \bmod i = 0: \text{ record } i, \text{ set } n = n / i

After the loop completes, if the remaining n > 1, it is itself a prime factor with exponent 1. The bound of √n works because any composite number n must have at least one prime factor less than or equal to √n. This makes trial division reasonably efficient for numbers up to about 10¹² — beyond that, more advanced algorithms like Pollard's rho or the quadratic sieve are needed.

For example, factoring 2,401 with trial division: √2,401 ≈ 49. Test 2, 3, 5, 7 — 7 divides evenly. 2,401 ÷ 7 = 343. Continue: 343 ÷ 7 = 49. Continue: 49 ÷ 7 = 7. Continue: 7 ÷ 7 = 1. Result: 2,401 = 7⁴.

Reference Table

Prime factorization of common numbers and their properties:

NumberPrime FactorizationDistinct PrimesTotal Divisors
122² × 326
302 × 3 × 538
722³ × 3²212
1002² × 5²29
1442⁴ × 3²215
2102 × 3 × 5 × 7416
3602³ × 3² × 5324
4202² × 3 × 5 × 7424
5042³ × 3² × 7324
10002³ × 5³216
Total number of divisors for selected numbers. Highly composite numbers like 360 have more divisors than their size would suggest.

The total divisor count comes from adding 1 to each exponent and multiplying. For 360 = 2³ × 3² × 5¹, the divisor count is (3+1)(2+1)(1+1) = 24. This formula is one of the most useful applications of prime factorization.

Practical Applications

Prime factorization appears in many real-world contexts beyond pure mathematics:

Cryptography

The RSA encryption algorithm depends on the difficulty of factoring the product of two large primes (each 2,048 bits or larger). Factoring such numbers with trial division would take longer than the age of the universe, which is what makes RSA secure. This calculator handles numbers well within the range of everyday mathematics — try factoring around 1,000,000 to see the algorithm in action.

Simplifying Fractions

When adding or subtracting fractions with different denominators, the least common denominator is found by taking the maximum exponent of each prime factor across all denominators. For example, adding 1/12 + 1/18: 12 = 2² × 3, 18 = 2 × 3². The LCD is 2² × 3² = 36. The Fraction Calculator handles this automatically.

Greatest Common Factor

The GCD of two numbers is found by taking the minimum exponent for each common prime factor. For 84 = 2² × 3 × 7 and 180 = 2² × 3² × 5, the GCD is 2² × 3 = 12. The GCF Calculator performs this calculation directly.

Least Common Multiple

The LCM is found by taking the maximum exponent for each prime factor. For the same numbers, the LCM is 2² × 3² × 5 × 7 = 1,260. The LCM Calculator provides this directly.

Limitations

Trial division becomes slow for very large numbers. This calculator is designed for numbers that fit within JavaScript's safe integer range (up to 9,007,199,254,740,991). Beyond that, the results may lose precision. For numbers larger than about 10¹², trial division may take several seconds — consider whether a full factorization is needed or if knowing that a number is composite is sufficient.

Prime factorization also assumes the Fundamental Theorem of Arithmetic, which applies only to integers. It does not apply to rational numbers, real numbers, or complex numbers. For exploring the properties of individual prime numbers, see the Factor Calculator.

Frequently Asked Questions

What is prime factorization?
Prime factorization is the process of expressing a composite number as a product of prime numbers. For example, the prime factorization of 84 is 2² × 3 × 7. Every composite number has exactly one prime factorization, a result known as the Fundamental Theorem of Arithmetic.
What is the difference between factors and prime factors?
Factors are all whole numbers that divide evenly into a given number. For 12, the factors are 1, 2, 3, 4, 6, and 12. Prime factors are the subset of factors that are prime numbers — for 12, the prime factors are 2 and 3 (with 2 appearing twice). The Factor Calculator finds all factors, while this calculator finds the prime factorization.
What is a prime number?
A prime number is an integer greater than 1 that has exactly two positive divisors: 1 and itself. The first few primes are 2, 3, 5, 7, 11, 13, 17, 19, 23, 29. The number 1 is not prime because it has only one divisor. The number 2 is the only even prime.
How does prime factorization help with fractions?
Prime factorization makes it easy to find common denominators and simplify fractions. For example, 12 = 2² × 3 and 18 = 2 × 3², so the least common denominator is 2² × 3² = 36. The fraction-calculator automates this process for you.
What is the largest number this calculator can factor?
This calculator can handle any positive integer up to 9 quadrillion (JavaScript's safe integer limit). Numbers above this may lose precision. Very large numbers near this limit may take a few seconds to factor using trial division.
Is prime factorization useful for cryptography?
Yes, the security of RSA encryption relies on the practical difficulty of factoring large composite numbers. RSA uses the product of two very large primes (each 2,048 bits), and factoring that product is computationally infeasible with current technology. This is why your online transactions are secure.
What is a factor tree?
A factor tree is a visual diagram that shows the step-by-step breakdown of a number into its prime factors. You start with the number at the top, draw two branches to any pair of factors, then continue branching each composite factor until all branches end at prime numbers. The audio description in this calculator covers the same logic as a factor tree.
How do I find the prime factorization of a large number quickly?
For numbers up to about 1 million, trial division works instantly. For numbers between 1 million and 10 billion, it may take a few seconds. For larger numbers, specialized algorithms like Pollard's rho or the general number field sieve are used. Online tools like Wolfram Alpha can handle much larger numbers than this calculator.
What is RSA encryption and how does it relate to prime factorization?
RSA is a public-key cryptosystem invented by Rivest, Shamir, and Adleman in 1978. Its security depends on the fact that while multiplying two large primes is easy, factoring the product back into the original primes is extremely difficult. This asymmetry enables secure encryption without needing to share a secret key.
Why is the number 1 not considered prime?
The number 1 is not prime because it has exactly one positive divisor (itself), whereas prime numbers must have exactly two distinct positive divisors (1 and themselves). Additionally, if 1 were considered prime, the Fundamental Theorem of Arithmetic would lose its uniqueness property, since you could multiply by any number of 1s.

Tips

When using prime factorization, keep three key ideas in mind. First, always check divisibility by 2 first — if the number is even, 2 is a factor. Then check 3 (by summing digits), 5 (by last digit), and continue with the remaining primes. This systematic approach ensures you don't miss small factors. Second, remember that once you find a factor, divide it out completely before checking the next divisor. The calculator does this automatically, but when working manually this step is critical because a factor may appear multiple times. Third, use the total divisor count formula to verify your factorization — if the product of (exponent + 1) matches the known divisor count from the Factor Calculator, your factorization is correct.

References

  1. [1]Weisstein, E. W. "Prime Factorization." From MathWorld—A Wolfram Web Resource.
  2. [2]Khan Academy. "Prime Factorization." Free online course.
  3. [3]Bogomolny, A. "Prime Factorization." Interactive Mathematics Miscellany and Puzzles.
  4. [4]Wolfram Demonstrations Project. "Prime Factorization." Interactive demonstration.
  5. [5]Niven, I., Zuckerman, H. S., and Montgomery, H. L. (1991). "An Introduction to the Theory of Numbers" (5th ed.). John Wiley & Sons.Buy on Amazon
  6. [6]Brilliant. "Prime Factorization." Interactive math learning resource.
  7. [7]Stapel, E. "Prime Factorization." Purplemath. Free math tutorial.

Last updated: July 30, 2026

1b

UnByte — Independent Software Engineering

Every calculator references authoritative sources — Editorial policy