1001Ferramentas
🔢 Dev

First N Primes Generator

List the first N prime numbers using the Sieve of Eratosthenes. Useful for number-theory exercises, educational cryptography demos and algorithm testing. Runs in your browser.

Lista dos N primeiros números primos, calculados via crivo de Eratóstenes no navegador.

Total: · Maior:

The first prime numbers, generated by sieve

A prime is a number greater than 1 divisible only by 1 and itself. The list starts 2, 3, 5, 7, 11 — and 2 is the only even one, which already explains why it turns up separately in almost every proof. Euclid showed over two thousand years ago that the list never ends, with an argument that fits in three lines: multiply all known primes, add 1, and the result is either prime or has a prime factor that was not on the list.

Enter how many primes you want and the page generates the sequence with the sieve of Eratosthenes, the right method for producing many primes at once: instead of testing each number, it strikes out the multiples of each prime found. The upper bound of the search comes from the prime number theorem, which estimates where the nth prime will be — without that estimate you would have to guess a ceiling and hope it fits.

One thing the list makes visible is how irregular the gaps are. Between 2 and 3 the distance is 1, between 89 and 97 it is 8, and arbitrarily long stretches exist with no primes at all. At the same time, twin primes — pairs two apart, like 11 and 13 — keep showing up as far as anyone has looked, though nobody has managed to prove they appear forever.

Frequently asked questions

Why is 1 not prime?
By deliberate convention, not caprice. If 1 were prime, factorisation would stop being unique: 6 would be 2×3, but also 1×2×3 and 1×1×2×3. The fundamental theorem of arithmetic depends on that uniqueness, so excluding 1 is what makes the whole structure work.
Why is the sieve better than testing one by one?
Because it never repeats work. Testing divisibility number by number redoes the same divisions countless times; the sieve marks each composite once per prime factor. To generate every prime up to a limit, it is orders of magnitude faster.
How many primes are there below a given number?
The prime number theorem answers approximately: below n there are around n divided by the natural logarithm of n. Up to a thousand that gives roughly 145, while the real count is 168 — the approximation improves as n grows, and it is what the page uses to size the sieve.

Related Tools