Prime Factorization by Trial Division

Breaks an integer into a product of primes by trial division, dividing by the smallest primes first. A number with a single prime factor is itself prime.

Prime factorization rewrites an integer as a product of primes. Every integer of 2 or more has exactly one such factorization, up to the order of the factors. That uniqueness is the fundamental theorem of arithmetic.

This calculator uses trial division. Divide by 2 as many times as it goes, then by 3, and so on upward. Once the divisor squared exceeds whatever is left, the search stops; anything greater than 1 still remaining must itself be prime.

Example

Factor n=360n = 360.

So 360=2×2×2×3×3×5360 = 2 \times 2 \times 2 \times 3 \times 3 \times 5, or in exponent form

360=23×32×5360 = 2^3 \times 3^2 \times 5

The number of prime factors, counting repeats, is 6.

Notes