The First One Million Prime Numbers

The first one million prime numbers span the range from 2 (the 1st prime) up to 15,485,863 (the 1,000,000th prime). This dataset shows how prime density decreases across larger intervals of the integers.

Key Boundary Values:

  • 1st Prime: 2 (the only even prime)
  • 100th Prime: 541
  • 1,000th Prime: 7,919
  • 10,000th Prime: 104,729
  • 100,000th Prime: 1,299,709
  • 1,000,000th Prime: 15,485,863

Milestone Table

The following table lists significant milestones among the first million prime numbers. The final column gives pn / n, the endpoint divided by the number of primes listed. It is a convenient measure of average range width per prime, but it is not the exact mean consecutive gap. For n > 1, that mean is (pn - 2) / (n - 1).

Rank (n) n-th Prime (pn) pn / n
1st 2 2.0
10th 29 2.9
100th 541 5.4
1,000th 7,919 7.9
10,000th 104,729 10.5
100,000th 1,299,709 13.0
500,000th 7,368,787 14.7
1,000,000th 15,485,863 15.5

From the 10th prime onward in this table, each tenfold increase in rank adds about 2.5 to this range-width measure. This slow growth is the practical face of the logarithm: primes thin out steadily, but far more gently than the size of the numbers themselves suggests. Sorted by digit length, the first million primes fall into these groups: 4 have one digit, 21 have two, 143 have three, 1,061 have four, 8,363 have five, 68,906 have six, 586,081 have seven, and the remaining 335,421 have eight.

The First 100 Prime Numbers

Written in order, the first one hundred primes are:

2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541

Distribution and Density

According to the Prime Number Theorem, the number of primes less than or equal to x is approximated by π(x) ≈ x / ln(x). Inverting this formula gives the approximation for the n-th prime:

pn ≈ n · (ln(n) + ln(ln(n)) - 1)

For n = 1,000,000, the asymptotic formula predicts p1,000,000 ≈ 15,441,302, which is within 0.3% of the true value of 15,485,863.

Running the estimate in the other direction is less flattering. The simple form x / ln(x) predicts only 935,394 primes below 15,485,863, an undercount of about 6.5%. The logarithmic integral li(x), which Gauss preferred, gives 1,000,411 against the true count of exactly 1,000,000. That is an error of four parts in ten thousand, illustrating why li(x) is often a substantially better elementary estimate than x / ln(x).

Two further totals for this range: the first million primes sum to 7,472,966,967,499, and the range contains 86,027 twin prime pairs, meaning about 17% of these primes have a partner just two away.

Ending Digit Distribution

Except for 2 and 5, every prime must end in one of four digits: 1, 3, 7, or 9. Any number ending in 0, 2, 4, 6 or 8 is divisible by 2, and any ending in 5 is divisible by 5. The four surviving digits are shared almost exactly evenly among the first million primes:

  • Primes ending in 1: 249,934 (24.993%)
  • Primes ending in 3: 250,110 (25.011%)
  • Primes ending in 7: 250,014 (25.001%)
  • Primes ending in 9: 249,940 (24.994%)
  • Primes ending in 2 & 5: Exactly 1 each (2 and 5)

The even split is not a coincidence. Dirichlet's theorem of 1837 guarantees that each of these four classes contains infinitely many primes, and the later prime number theorem for arithmetic progressions establishes that the four shares approach 25% each.

A subtler pattern appears when consecutive primes are compared rather than counted in isolation. Among the primes here that end in 1, only about 17% are followed by another prime ending in 1, well short of the 25% that independence would predict. Robert Lemke Oliver and Kannan Soundararajan described this reluctance of consecutive primes to repeat a final digit in 2016. The bias fades as numbers grow, but it does so slowly enough to remain plainly visible across this entire range.

Notable Prime Gaps

While the average gap between primes near the 1,000,000th prime is roughly ln(15,485,863) ≈ 16.55, prime gaps vary widely. The largest prime gap occurring within the first million primes is a gap of 154, between the primes 4,652,353 and 4,652,507. That stretch of 153 consecutive composite numbers is more than nine times the local average.

Gaps do not grow steadily; they set records at irregular intervals. Within this range the maximum climbs from 34 after 1,327, to 72 after 31,397, to 112 after 370,261, to 148 after 2,010,733, and finally to 154 after 4,652,353, which then stands unbeaten for the remaining two thirds of the range.

At the other extreme, the gap of 1 occurs once only, between 2 and 3, since every later pair of consecutive primes is a pair of odd numbers. The most frequent gap is not the smallest but 6, which occurs 146,518 times and outnumbers the twin gap of 2 by well over half. Gaps of 12 come second at 97,826. Small even gaps that are multiples of 6 dominate because a prime pair differing by 2 or 4 must dodge divisibility by 3, while a pair differing by 6 faces no such constraint.

How to Generate the First Million Primes

Generating the first 1,000,000 primes is a modest computation on modern hardware using the Sieve of Eratosthenes up to the limit of 15,485,863. Exact running time depends on the implementation, language and processor. For memory efficiency, bit-level boolean arrays or a segmented sieve can keep the sieve's working memory under 2 MB.

The arithmetic behind that figure is straightforward. One bit per candidate over 15,485,863 values needs about 1.9 MB, and skipping the even numbers halves it to roughly 970 KB, compact enough to benefit from cache locality on many modern processors. Storing the resulting primes is the more expensive step: one million values at four bytes each occupy about 4 MB, which is more than the compact sieve that produced them.

One practical detail catches people out. To obtain exactly one million primes you must know the upper limit in advance, and 15,485,863 is that limit only because the answer is already known. Working from a target count instead, a safe approach is to sieve up to the estimate n · (ln(n) + ln(ln(n))), which overshoots slightly for all n ≥ 6, then discard the surplus.

Verify a Prime

Use our Prime Number Check to test a specific integer in or beyond this list, up to the checker's 20,000-digit limit, or read about how to check whether a number is prime and cash awards for prime number money prizes.

Sources & Further Reading

  1. Wikipedia: Prime number theorem - Historical development and mathematical proofs of prime density estimates.
  2. Wikipedia: Logarithmic integral function - Analysis of the li(x) and Li(x) approximations and their accuracy in prime counting.
  3. Wikipedia: Prime gap - Differences between consecutive primes, maximal gap records, and asymptotic conjectures.
  4. Wikipedia: Dirichlet's theorem on arithmetic progressions - Equidistribution proofs for prime ending digits across modular congruence classes.
  5. OEIS Sequence A000040: The Prime Numbers - Online Encyclopedia of Integer Sequences entry for the primes.
  6. OEIS Sequence A002386: Maximal gaps between primes - Verified records of maximum distances between consecutive prime values.
  7. Proceedings of the National Academy of Sciences (PNAS) - Research paper by Robert Lemke Oliver and Kannan Soundararajan on consecutive prime digit biases.