Prime factorization: how to factor any number, test primality and count divisors
Every whole number greater than 1 is either prime or can be written as a product of primes in exactly one way (apart from order). This is the Fundamental Theorem of Arithmetic, and the product is called the prime factorization. It underlies simplifying fractions, finding GCDs and LCMs, counting divisors and, at a much larger scale, the security of RSA encryption.
The solver uses trial division by 2, 3 and then numbers of the form 6k ± 1 up to √n, which is fast for any number up to 10¹⁵. It lists each division, gives the exponent form, and computes the number and sum of divisors.
Key formulas
n = p₁^e₁ · p₂^e₂ · … · p_k^e_kd(n) = (e₁ + 1)(e₂ + 1)…(e_k + 1)σ(n) = Π (p^(e+1) − 1)/(p − 1)Worked examples
Find the prime factorization of 360.
- 360 ÷ 2 = 180, ÷ 2 = 90, ÷ 2 = 45.
- 45 ÷ 3 = 15, ÷ 3 = 5.
- 5 is prime.
Test 9973.
- √9973 ≈ 99.86, so test primes up to 97.
- None divide evenly.
Factor 496.
- 496 = 2⁴ × 31.
- σ = (2⁵ − 1) × (31 + 1) = 31 × 32 = 992 = 2 × 496.
Factor 600,851,475,143.
- Trial division finds 71, 839, 1471 and 6857.
Use prime factorizations to find the GCD and LCM of 84 and 90.
- 84 = 2² × 3 × 7 and 90 = 2 × 3² × 5.
- GCD: take each prime the two numbers share, with the smaller exponent: 2¹ × 3¹ = 6.
- LCM: take every prime that appears, with the larger exponent: 2² × 3² × 5 × 7 = 1,260.
- Check: GCD × LCM = 6 × 1,260 = 7,560 = 84 × 90.
84How many divisors does 720 have, and what is their sum?
- 720 = 2⁴ × 3² × 5.
- Each divisor picks an exponent of 2 from 0–4 (5 choices), of 3 from 0–2 (3 choices) and of 5 from 0–1 (2 choices): 5 × 3 × 2 = 30 divisors.
- The sum of divisors multiplies (1 + 2 + … + 2⁴) × (1 + 3 + 3²) × (1 + 5) = 31 × 13 × 6 = 2,418.
720Divisibility shortcuts
| Divisor | Rule |
|---|---|
| 2 | Last digit even |
| 3 | Digit sum divisible by 3 |
| 4 | Last two digits divisible by 4 |
| 5 | Ends in 0 or 5 |
| 9 | Digit sum divisible by 9 |
| 11 | Alternating digit sum divisible by 11 |
Why big factorizations are hard
Multiplying two 300-digit primes takes a computer microseconds, but recovering them from the product would take the best known algorithms longer than the age of the universe. That asymmetry is what keeps RSA-encrypted web traffic secure. For the sizes here (up to 15 digits) trial division is instant.
Simplifying square roots with a factorization
Pair up equal prime factors: every pair can leave the square root as a single factor. For 720 = 2⁴ × 3² × 5, the pairs 2² × 2² and 3² give 2 × 2 × 3 = 12 outside the root, and the unpaired 5 stays inside, so √720 = 12√5 ≈ 26.83. The same idea finds the smallest number to multiply by to get a perfect square: 720 × 5 = 3,600 = 60².
Common mistakes to avoid
- Listing a composite factor (like 9) instead of breaking it into primes (3²).
- Stopping before the remaining quotient is prime.
- Forgetting that 1 is not a prime number.
- Testing divisors beyond √n unnecessarily.
Frequently asked questions
Is 1 a prime number?
What is the largest number I can factor here?
How do prime factorizations help with fractions?
Why is the prime factorization of a number unique?
How do I tell whether a number is a perfect square from its factorization?
Related tools and guides
Educational content. Results are computed in your browser with standard double-precision arithmetic; double-check anything with legal, financial, medical, or safety consequences. Spotted an error? Tell us and we will correct it.