Prime factorization

Edit the example and calculate.

Enter a positive integer and get its prime factorization with exponents, such as 84 = 2² × 3 × 7. You see the factor tree, whether the number is prime or composite, and a check that multiplies the factors back together to confirm the result.

Enter an integer from 1 to 1,000,000,000,000. The calculation runs in a separate worker so the page stays responsive.

Result

Exact

Complete the fields and select Calculate.

Factor a positive integer into prime powers and read its factor tree.

To check whether a number is prime, enter it here. The result identifies prime, composite, or the special case of 1.

Example: 360 = 2³ × 3² × 5.

Worked example

Factor tree for 360

Split each composite number into two factors. Continue until every leaf is prime: three factors of 2, two of 3, and one of 5.

360 = 36 × 10; 36 = 4 × 9; 4 = 2 × 2; 9 = 3 × 3; 10 = 2 × 5. Leaves: 2, 2, 3, 3, 2, 5. 360 = 2³ × 3² × 5 = 8 × 9 × 5.

How is this result checked?Report an errorHow we handle corrections

Key facts

Unique result
Every integer greater than 1 is written in only one way as a product of primes, not counting order: 60 = 2² × 3 × 5.
Notation
The result uses ^ for the exponent: 2^2 × 3 × 5 means 4 × 3 × 5 = 60. A prime without ^ appears once.
Prime or composite
91 looks prime but is not: 91 = 7 × 13. Testing divisors up to the square root of the number is enough.
The number 1
1 is neither prime nor composite, and its list of prime factors is empty.
Small primes
The first primes are 2, 3, 5, 7, 11, and 13. The number 2 is the only even prime.

Formula

n = p₁^a₁ × p₂^a₂ × … × pₖ^aₖ

Example:1001 = 7 × 11 × 13

The p values are distinct primes in increasing order, and each a counts how many times its prime repeats.

Published

Enter an integer from 1 to 1,000,000,000,000 (10¹²) and select “Calculate.” For the complete list of divisors, use the factors calculator.

Worked example: 360 as prime factors

Write 360 as a product of primes.

  1. Divide by 2 as long as you can. 360 ÷ 2 = 180, 180 ÷ 2 = 90, and 90 ÷ 2 = 45. The number 45 is odd, so the 2s run out with exponent 3.
  2. Move on to 3. 45 ÷ 3 = 15 and 15 ÷ 3 = 5. The 3 appears twice.
  3. One prime is left. The 5 is divisible only by 1 and itself.
  4. Group the repeated factors. 2 × 2 × 2 × 3 × 3 × 5 = 2³ × 3² × 5.

Result: 360 = 2³ × 3² × 5. In the result it appears as 2^3 × 3^2 × 5.

Check: 8 × 9 × 5 = 72 × 5 = 360. The result check repeats this same multiplication.

The method is always the same: try 2, then the odd numbers 3, 5, 7, 9…, and stop when the square of the candidate is larger than what is left to divide. What is left at that point is a prime.

The result does not depend on the path

You can also start with 360 = 36 × 10, then 36 = 4 × 9, 4 = 2 × 2, 9 = 3 × 3, and 10 = 2 × 5. The leaves of the tree are again three 2s, two 3s, and one 5. This is the fundamental theorem of arithmetic: the tree changes shape, but the product of prime powers is always the same. That is why you can compare the factorizations of two numbers to find their GCF (also called the GCD or HCF) or their LCM.

Prime, composite, or neither

A number is composite if it has a divisor other than 1 and itself. To decide, you do not need to test every integer: if n = a × b, one of the two factors is less than or equal to the square root of n. For 97, the root falls between 9 and 10 because 9² = 81 and 10² = 100. The primes 2, 3, 5, and 7 leave remainders 1, 1, 2, and 6, so 97 is prime. The divisibility rules rule out 2, 3, and 5 at a glance.

Cases worth telling apart
NumberFactorizationWhat it shows
9797Prime: no prime up to 7 divides it
917 × 13Composite that looks prime
10017 × 11 × 13Three consecutive primes
10242^10Power of a single prime
999,9993^3 × 7 × 11 × 13 × 37Six digits, five distinct primes
1no factorsNeither prime nor composite

If the list has a single factor with no exponent, the number is prime; if it has a single prime with an exponent, like 1024, the number is a power of that prime.

What you can get from the factorization

With 18 = 2 × 3² and 24 = 2³ × 3, the GCF takes each common prime with the smaller exponent, 2 × 3 = 6, and the LCM takes every prime with the larger exponent, 2³ × 3² = 72. This page does not calculate those two values; to get them directly, use the GCD calculator or the LCM calculator. With the GCF of 6, you simplify 18/24 to 3/4 in the simplify fractions tool.

The exponents also count divisors: add 1 to each one and multiply. With the exponents 3, 2, and 1 of 360, you get (3 + 1) × (2 + 1) × (1 + 1) = 24 divisors, and the complete list is in the factors calculator. And if all the exponents are even, the number is a perfect square: 144 = 2⁴ × 3² = (2² × 3)².

How it handles large numbers

The search uses trial division. No candidate goes past the square root. At the limit of 10¹², that is about 500,000 trials at most, because only 2 and the odd numbers are tried. If a calculation takes a while, a “Cancel calculation” button appears. A number larger than 10¹² gets no verdict of prime or composite. As an example, 10¹² = 2^12 × 5^12 and 999,999,999,989 is prime.

Frequently asked questions

Why isn't 1 considered prime?

A prime has exactly two positive divisors, 1 and itself, and 1 has only one. Also, if 1 counted as prime, the factorization of 10 would not be unique: 2 × 5, 1 × 2 × 5, 1 × 1 × 2 × 5, and so on forever. That is why the list of prime factors of 1 is empty.

Can I factor a negative number, a decimal, or zero?

No, only positive integers are accepted. For a negative number, factor its absolute value and add the sign: −50 = −(2 × 5²). Zero has no factorization, because every prime divides it. For a decimal, first write it as a fraction (0.6 = 3/5) and factor the numerator and denominator separately.

Next step

Greatest common divisor (GCD) Find the greatest common divisor (GCD) of 2 to 20 integers with Euclid’s algorithm, step by step: GCD(48, 18) = 6.

YOUR CALCULATOR, CLOSE AT HAND

Save your calculator

Open your browser menu and choose “Install app” or “Add to Home Screen”. You can also bookmark this page.