Prime Factorization Calculator

Break any whole number into its prime factors, check whether it's prime, and list all of its divisors.

Updated · Free · Runs in your browser

Prime factorization —
Prime or composite —
Expanded form —
Number of divisors —
Divisors —
Properties —
    Was this calculator helpful?

    The formula

    Divide by the smallest prime (2, 3, 5, 7, 11…) repeatedly until the quotient is 1
    n = p₁^a₁ × p₂^a₂ × … × pₖ^aₖ
    Number of divisors = (a₁ + 1)(a₂ + 1)…(aₖ + 1)
    Sum of divisors σ(n) = Π (pᵢ^(aᵢ+1) − 1) ÷ (pᵢ − 1)

    Worked example

    1. 360 ÷ 2 = 180, ÷ 2 = 90, ÷ 2 = 45, ÷ 3 = 15, ÷ 3 = 5, ÷ 5 = 1.
    2. So 360 = 2 × 2 × 2 × 3 × 3 × 5 = 2³ × 3² × 5.
    3. Number of divisors = (3 + 1)(2 + 1)(1 + 1) = 24.
    4. The divisors add up to 1,170, more than 2 × 360, so 360 is abundant.

    What prime factorization means

    A prime number has exactly two divisors, 1 and itself: 2, 3, 5, 7, 11, 13 and so on. Every whole number greater than 1 is either prime or can be written as a product of primes in exactly one way, apart from the order of the factors. This is the fundamental theorem of arithmetic. The prime factorization of 360 is 2³ × 3² × 5, and no other combination of primes multiplies to 360. Prime factors are the building blocks of numbers, in the same way that atoms are the building blocks of molecules.

    How to find prime factors by hand

    The simplest method is repeated division. Divide the number by 2 as many times as you can, then by 3, then 5, then 7, and so on through the primes, until the quotient is 1. You only need to test primes up to the square root of the remaining number: if none divides it, what's left is prime. A factor tree is a visual version: split the number into any two factors, then keep splitting until every branch ends in a prime. Divisibility rules help: a number is divisible by 3 if its digits add up to a multiple of 3, and by 5 if it ends in 0 or 5.

    How the calculator handles big numbers

    For numbers up to 30 digits, the calculator uses exact big-integer arithmetic, so there's no rounding. It first tries trial division by small primes, then uses the Miller–Rabin test to check whether what's left is prime, and Pollard's rho algorithm to split large composite numbers. Products of two very large primes, such as those used in RSA encryption, are deliberately hard to factor, and a 30-digit number made of two 15-digit primes may be reported as not fully factored. That difficulty is exactly what keeps online encryption secure.

    Divisors and special numbers

    Once you have the prime factorization, counting divisors is easy: add one to each exponent and multiply. 360 has (3 + 1)(2 + 1)(1 + 1) = 24 divisors, which is one reason ancient Babylonians chose it for the degrees in a circle. A number is a perfect square if every exponent is even. A perfect number equals the sum of its proper divisors, like 6 = 1 + 2 + 3 and 28 = 1 + 2 + 4 + 7 + 14; abundant numbers have divisors adding to more than the number, and deficient numbers to less.

    Using prime factors for GCD, LCM and fractions

    Prime factorizations make it easy to find the greatest common divisor and least common multiple of numbers. For the GCD, multiply the primes the numbers share, using the lowest power of each; for the LCM, multiply every prime that appears, using the highest power. For 360 = 2³ × 3² × 5 and 84 = 2² × 3 × 7, the GCD is 2² × 3 = 12 and the LCM is 2³ × 3² × 5 × 7 = 2,520. Our GCD and LCM calculator does this for any set of numbers, and the fraction calculator uses the GCD to simplify fractions.

    Primes in everyday technology

    Primes are central to modern cryptography. RSA and related systems that secure websites, banking and messaging rely on the fact that multiplying two large primes is easy but factoring the result is extremely hard. Modular arithmetic with primes also powers hashing, random number generators and error-correcting codes. To experiment with the modular powers used in RSA, try our modulo calculator, and for counting problems that involve factorials, use the permutation and combination calculator.

    Frequently asked questions

    How do I find the prime factorization of a number?
    Divide by the smallest prime that goes in evenly, and repeat with the result until you reach 1. The primes you divided by, with repeats, are the prime factorization.
    Is 1 a prime number?
    No. A prime has exactly two different divisors, and 1 has only one. Excluding 1 keeps every number's prime factorization unique.
    What is the prime factorization of 100?
    100 = 2² × 5², or 2 × 2 × 5 × 5.
    How many divisors does a number have?
    Write its prime factorization, add 1 to each exponent and multiply. 72 = 2³ × 3² has (3 + 1)(2 + 1) = 12 divisors.
    What is the largest known prime?
    As of 2024, it's the Mersenne prime 2^136,279,841 − 1, which has more than 41 million digits. It was found by the GIMPS distributed computing project.

    ↑↓ to navigate · Enter to open