Prime Factorization Formula – Fundamental Theorem of Arithmetic

The complete prime factorization formula with variable definitions, divisor-count formula, GCD and LCM derivations, and four fully worked examples.

Formula
Every integer n > 1 can be uniquely expressed as an ordered product of prime powers. The exponents eᵢ are positive integers, and the primes p₁ < p₂ < … < pₖ are distinct.
Variables
SymbolNameDescriptionUnit
nInteger to factorizeThe positive integer being decomposed into prime factors (n > 1)
pᵢPrime factorThe i-th distinct prime divisor of n, listed in increasing order
eᵢExponentThe number of times prime pᵢ divides n exactly; always ≥ 1
kNumber of distinct primesThe count of unique prime factors of n
τ(n)Divisor countTotal number of positive divisors of n: τ(n) = (e₁+1)(e₂+1)⋯(eₖ+1)
How to Use
  1. Divide n by 2 as many times as possible. Record each division.
  2. Try odd divisors d = 3, 5, 7, … up to √n, dividing each time d divides the remaining quotient.
  3. If the remaining quotient after the loop is greater than 1, it is itself a prime factor.
  4. Group repeated prime factors using exponents to write the compact exponential form.
  5. Compute τ(n) = (e₁+1)(e₂+1)⋯(eₖ+1) to find the total number of divisors.
Examples
1. Factorize 360

Divide repeatedly by 2, then by 3, then check remaining factors.

StepNumber÷Quotient
13602180
2180290
390245
445315
51535
6551
360 has 3 distinct prime factors and 24 total divisors.
2. Factorize 2,310 — a primorial

2,310 = 2 × 3 × 5 × 7 × 11 is the product of the first five primes (called a primorial). Each prime appears exactly once.

StepNumber÷Quotient
1231021155
211553385
3385577
477711
511111
When all exponents are 1, the divisor count is 2^k where k is the number of prime factors.
3. GCD and LCM from factorizations

Find GCD(360, 756) and LCM(360, 756).

PrimeExp in 360Exp in 756GCD (min)LCM (max)
23223
32323
51001
70101
Verify: GCD × LCM = 36 × 7560 = 272,160 = 360 × 756. ✓
4. Is 1,000,003 prime? (large number trial division)

We only need to test divisors up to √1,000,003 ≈ 1000.0015. Test primes up to 1000.

After testing all primes ≤ 1000 (there are 168 of them), none divide 1,000,003 evenly.

The trial division upper bound is √n, not n. For n = 10⁶, only ~168 prime divisors need to be tested — making trial division very efficient for numbers up to 10¹².