Prime Factorization, GCF, and LCM Explained

How to factor a number into primes by trial division, read GCF and LCM straight off the exponents, and count divisors without listing them.

5 min read Updated Jul 2026

Quick Answer

What the fundamental theorem of arithmetic says is simple: every whole number above 1 breaks into prime numbers in exactly one way. To find the prime factorization, divide out the smallest prime repeatedly, then the next, until 1 remains. For example, 360 = 2³ × 3² × 5. From two factorizations you can read the greatest common factor (shared primes, lower exponents) and the least common multiple (all primes, higher exponents) without any guessing. This prime factorization calculator narrates the divisions, works as a gcf calculator and lcm calculator against a second number, and counts divisors from the exponents.

Try The Prime Factorization Calculator →

How Prime Factorization Works

The method is trial division, the tidy version of a factor tree. Start with the smallest prime, 2, and divide as many times as it fits: 360 becomes 180, 90, then 45, so 2³ divides in. Move to 3: 45 becomes 15, then 5, so 3² divides in. The remainder 5 is itself prime, and the chain reads 360 = 2³ × 3² × 5. Two facts make this fast. First, you only ever need to test primes, because any composite divisor would have been consumed by its own prime parts earlier. Second, you only need primes up to the square root of what remains: factors pair up around the square root, so if nothing at or below it divides, the remainder is prime. Therefore even a number near a trillion settles in at most a million quick divisions.

Reading GCF and LCM off the Exponents

Once two numbers are factored, their greatest common factor and least common multiple stop being search problems. Line the factorizations up prime by prime. The GCF collects the primes both numbers share, each at its lower exponent, because a common factor cannot use more of a prime than either number owns. The LCM collects every prime that appears anywhere, each at its higher exponent, because a common multiple must cover both. For 36 = 2² × 3² and 60 = 2² × 3 × 5 that gives GCF = 2² × 3 = 12 and LCM = 2² × 3² × 5 = 180. The whole GCF versus LCM distinction is lower-versus-higher exponents. When two numbers share no prime at all they are coprime numbers and the GCF is 1. The GCF is what simplifies a fraction in one step, and the LCM is the least common denominator when adding fractions.

Examples

For example, factor 360. The chain 360 → 180 → 90 → 45 → 15 → 5 → 1 gives 2³ × 3² × 5, and (3+1) × (2+1) × (1+1) = 24 divisors follow from the exponents alone.

GCF and LCM of 36 and 60. Shared primes at lower exponents: 2² × 3 = 12. All primes at higher exponents: 2² × 3² × 5 = 180.

Is 97 prime? Only 2, 3, 5, and 7 sit at or below √97; none divides 97, so it is prime, no further checks needed.

This Calculator vs the Alternatives

Drawing a factor tree by hand teaches the idea but gets error-prone past two digits, and a pocket calculator can divide yet never tells you which prime to try next. Most online tools print the factorization as a bare answer. Here the trial divisions are narrated line by line, exactly the working a teacher expects, and this factor tree calculator doubles as a prime factor calculator, a primality check, and a gcf and lcm calculator in one pass. However, the point of the steps is practice: cover the answer, factor by hand, then compare chains.

Counting Divisors Without Listing Them

Building a divisor of 2³ × 3² × 5 means deciding how many 2s to include (0 to 3), how many 3s (0 to 2), and how many 5s (0 or 1). Choices multiply: 4 × 3 × 2 = 24 divisors, no listing required. The same idea explains why highly divisible numbers such as 360 were used for calendars and circles: small primes at generous exponents create many divisors.

Common Mistakes