Prime Factorization & Sieve Visualizer
Factor any number into primes and see a branching factor tree. Or animate the Sieve of Eratosthenes to watch primes being found step by step as composites are crossed out by color.
Factor Tree
Teal = prime leaf Amber = composite
Step-by-Step Division
Prime Factors
GCD and LCM with Related Numbers
| Number pair | GCD | LCM |
|---|---|---|
| 60 and 4 | 4 | 60 |
| 60 and 9 | 3 | 180 |
| 60 and 25 | 5 | 300 |
Reference Guide
Prime Numbers
A prime number is a whole number greater than 1 that has exactly two divisors: 1 and itself. The first primes are 2, 3, 5, 7, 11, 13, 17, 19, 23...
2 is the only even prime. All other even numbers are divisible by 2, so they are composite. There are infinitely many primes, as Euclid proved around 300 BCE.
The prime-counting function counts primes up to . It grows roughly as by the Prime Number Theorem.
Fundamental Theorem of Arithmetic
Every integer greater than 1 is either prime or can be written as a unique product of prime numbers (up to the order of the factors). This is the Fundamental Theorem of Arithmetic.
A factor tree finds prime factors by repeatedly splitting a composite number. Every path from root to leaf ends at a prime. No matter how you split, you always get the same set of primes.
Sieve of Eratosthenes
The Sieve of Eratosthenes is an ancient algorithm for finding all primes up to a limit . The steps:
- Write out numbers 2 through .
- Find the first unmarked number (a prime). Cross out all its multiples starting from its square.
- Repeat until you reach . All remaining unmarked numbers are prime.
GCD and LCM
The Greatest Common Divisor (GCD) is the largest number that divides both and . The Least Common Multiple (LCM) is the smallest number divisible by both.
Using prime factorizations, take the product of shared primes (minimum exponents) for the GCD, and the product of all primes (maximum exponents) for the LCM. The identity always holds.