Prime Factorization Calculator
Decompose any integer up to 1 trillion into its prime factors. Shows the factorization in exponent notation, distinct prime count ω(n), and total divisors τ(n).
Inputs
Results
Definition
Every integer greater than 1 can be written as a product of prime numbers. This representation is called the prime factorization. For example:
The primes 2, 3, and 5 are the "atoms" of 360 — they cannot be divided further. The exponents (3, 2, and 1) record how many times each prime appears.
The Fundamental Theorem of Arithmetic
The Fundamental Theorem of Arithmetic guarantees two things:
- Existence: Every integer greater than 1 has at least one prime factorization.
- Uniqueness: Every integer greater than 1 has exactly one prime factorization (up to the order of factors).
This theorem is the cornerstone of number theory. Without it, arithmetic concepts like GCD, LCM, and divisibility would be far more complicated.
Why is 1 excluded? If 1 were prime, factorizations would no longer be unique — an extra factor of 1 could always be inserted. Excluding 1 from the primes preserves uniqueness.
How Trial Division Works
The most straightforward way to factor is trial division: test every integer from 2 up to as a potential factor.
Step-by-step for n = 360:
- Is 360 divisible by 2? Yes: . Keep dividing: , . Now 45 is odd. Factor: 2³.
- Is 45 divisible by 3? Yes: , . Now 5 is not divisible by 3. Factor: 3².
- Is 5 divisible by 5? Yes: . Factor: 5¹.
- Nothing remains. Result: .
Why only up to ? If has a factor , then , meaning a smaller factor must already exist. When no factor is found, itself must be prime.
Factor Trees
A factor tree is a visual method for finding prime factors: a number is repeatedly split into any two factors until every branch ends in a prime.
360
/ \
4 90
/ \ / \
2 2 9 10
/ \ / \
3 3 2 5
The leaves give the prime factorization: 2, 2, 2, 3, 3, 5 → 2³ · 3² · 5.
Factor trees always reach the same result regardless of the order in which the splits are made — a direct consequence of uniqueness.
Counting Divisors
A direct application of prime factorization is counting divisors. If:
then the total number of positive divisors is:
Why? Each divisor of is formed by independently selecting an exponent for each prime: any value from 0 to for prime . That gives choices per prime, and the choices multiply.
Example — divisors of 360:
So 360 has exactly 24 positive divisors.
GCD and LCM via Prime Factorization
Given the factorizations of two numbers, their GCD and LCM follow directly:
- GCD: take the minimum exponent for each prime.
- LCM: take the maximum exponent for each prime.
Example: GCD and LCM of 360 and 504
| Prime | 360 | 504 | min (GCD) | max (LCM) |
|---|---|---|---|---|
| 2 | 3 | 3 | 3 | 3 |
| 3 | 2 | 2 | 2 | 2 |
| 5 | 1 | 0 | 0 | 1 |
| 7 | 0 | 1 | 0 | 1 |
Simplifying Fractions
To reduce to lowest terms, divide numerator and denominator by .
Applications Beyond Arithmetic
| Field | How prime factorization helps |
|---|---|
| Cryptography | RSA security rests on the difficulty of factoring the product of two large primes |
| Hash functions | Choosing hash-table sizes as primes reduces collisions |
| Coding theory | Generator polynomials in error-correcting codes factor over finite fields |
| Music theory | Just intonation intervals are ratios of small prime powers (2, 3, 5) |
Special Cases
- n = 2 (smallest prime): Factorization is 2 itself; exactly 2 divisors (1 and 2).
- n is prime: Factorization is just itself; it has exactly 2 divisors (1 and ).
- Perfect powers: Numbers like 1024 = 2¹⁰ have only one distinct prime factor; their divisor count is $e + 1 = 11$.
- Highly composite numbers: Numbers with unusually many divisors (e.g., 360, 720, 1260) have small primes with large exponents.
Quick Reference
| Concept | Formula |
|---|---|
| Factorization | |
| Distinct prime count | |
| Total divisor count | |
| GCD of two numbers | product of primes with minimum exponents |
| LCM of two numbers | product of primes with maximum exponents |
| GCD × LCM identity |
Frequently Asked Questions (FAQ)
What is prime factorization?
Prime factorization is the process of expressing a positive integer as a product of prime numbers. For example, 360 = 2³ · 3² · 5. Every integer greater than 1 can be written this way, and the Fundamental Theorem of Arithmetic guarantees the representation is unique (up to the order of factors).
Is every number's prime factorization unique?
Yes. The Fundamental Theorem of Arithmetic states that every integer greater than 1 has exactly one prime factorization (ignoring the order of factors). This uniqueness is what makes prime factorization so powerful in number theory — it is the "atomic decomposition" of integers.
How do I count all divisors from the prime factorization?
If n = p₁^e₁ · p₂^e₂ · … · pₖ^eₖ, then the total number of positive divisors is τ(n) = (e₁+1)(e₂+1)…(eₖ+1). For 360 = 2³ · 3² · 5¹, τ(360) = 4 · 3 · 2 = 24, so 360 has 24 divisors in total.
What is the largest number this calculator can factor?
This calculator supports integers up to 1,000,000,000,000 (10¹², one trillion). It uses trial division up to √n, which requires at most about one million iterations — fast enough to run in the browser. If you need to factor larger numbers, specialized algorithms such as Pollard's rho or quadratic sieve are used.