Prime Factorization Calculator
Decompose any integer into its prime building blocks, with divisor count and sum-of-divisors as bonus statistics.
Decompose any positive integer up to 253 into its prime factors using trial division by 2 and odd numbers.
Why prime factorisation?
Every positive integer greater than 1 can be written as a product of primes in essentially one way. That fact — the fundamental theorem of arithmetic — is the spine of number theory and underlies most of modern cryptography. Knowing the prime factorisation of a number tells you almost everything else about it: how many divisors it has, what those divisors sum to, whether it is a perfect square, whether two numbers share factors, and so on.
How the calculator finds factors
The calculator uses straightforward trial division: divide out 2 first, then odd numbers from 3 upwards, stopping when the divisor exceeds the square root of the remaining number. That is fast for numbers up to about 10¹⁴ — well within the 2⁵³ = 9.007 × 10¹⁵ ceiling that JavaScript’s safe-integer range allows.
Divisor count and sum
If a number n has prime factorisation p₁^a₁ × p₂^a₂ × …, then the number of divisors is (a₁ + 1)(a₂ + 1)… and the sum of divisors is (p₁^(a₁+1) − 1)/(p₁ − 1) × (p₂^(a₂+1) − 1)/(p₂ − 1) × …. The calculator computes both directly from the factor list, so they are exact rather than approximate.