Sieve of Eratosthenes — Interactive Prime Number Finder

simulator beginner ~8 min
Loading simulation...
25 primes — found below 100 using the Sieve of Eratosthenes

There are 25 prime numbers less than 100. The Sieve of Eratosthenes finds them by systematically eliminating multiples of each prime starting from 2.

Formula

pi(N) ~ N / ln(N) (Prime Number Theorem)
Sieve complexity: O(N * log(log(N)))

The Oldest Algorithm

The Sieve of Eratosthenes, dating to roughly 240 BC, is one of the oldest known algorithms still in practical use. Eratosthenes of Cyrene — the same polymath who measured the Earth's circumference — devised a simple method: write down all numbers, then systematically cross out multiples of each prime. What remains is the complete list of primes.

How the Sieve Works

Start with 2, the smallest prime. Cross out 4, 6, 8, 10... (all multiples of 2). The next uncrossed number is 3 — cross out 9, 15, 21... (multiples of 3 not already crossed). Continue with 5, 7, 11... You only need to sieve up to the square root of your maximum number, because any composite number must have a factor less than or equal to its square root.

The Distribution of Primes

Primes become sparser as numbers grow, but they never run out — Euclid proved this around 300 BC. The Prime Number Theorem, proved independently by Hadamard and de la Vallee Poussin in 1896, quantifies the thinning: roughly 1 in every ln(N) numbers near N is prime. The exact distribution connects to the Riemann Hypothesis, the greatest unsolved problem in mathematics.

Primes and Cryptography

Modern internet security rests on prime numbers. RSA encryption uses the product of two large primes as a public key. Multiplying two 300-digit primes is easy, but factoring the result back into its prime components would take longer than the age of the universe with current algorithms. This asymmetry is the foundation of secure digital communication.

FAQ

What is the Sieve of Eratosthenes?

It is an ancient algorithm attributed to the Greek mathematician Eratosthenes (c. 240 BC). Starting from 2, it marks all multiples of each prime as composite. The unmarked numbers that remain are prime. It is one of the most efficient ways to find all small primes.

How many primes are there below N?

The Prime Number Theorem states that the number of primes below N is approximately N/ln(N). For N=100 there are 25 primes, for N=1000 there are 168, and for N=1,000,000 there are 78,498. Primes thin out but never stop.

Why are prime numbers important?

Primes are the building blocks of all integers (the Fundamental Theorem of Arithmetic). They are also the foundation of modern cryptography — RSA encryption relies on the difficulty of factoring large numbers into their prime components.

What is the largest known prime number?

The largest known primes are Mersenne primes of the form 2^p - 1. As of recent records, the largest has tens of millions of digits. The Great Internet Mersenne Prime Search (GIMPS) project coordinates distributed computing to find these giants.

Sources

Embed

<iframe src="https://homo-deus.com/lab/mathematics/prime-sieve/embed" width="100%" height="400" frameborder="0"></iframe>