Nth Prime Number Calculator

Find the nth prime number, for example the 1000th prime, with the neighbouring primes and the n(ln n + ln ln n) estimate. For n ≥ 6 the nth prime p(n) satisfies p(n), so a sieve up to that bound is guaranteed to contain it. Example: with position n 100, the result is The 100th prime number = 541.

Last updated · By · Runs in your browser, nothing is uploaded

Result

Step-by-Step Solution

Enter your values above to see the full working.

How do you use the Nth Prime Number Calculator?

Enter a position n up to 200,000. The calculator sieves up to a proven upper bound and returns the nth prime, together with the previous and next primes and the asymptotic estimate.

What formula does the Nth Prime Number Calculator use?

For n ≥ 6 the nth prime p(n) satisfies p(n) < n(ln n + ln ln n), so a sieve up to that bound is guaranteed to contain it. The prime number theorem gives the approximation p(n) ≈ n ln n.

Worked example: Position n 100

The 100th prime is 541. The bound formula gives 100 × (ln 100 + ln ln 100) ≈ 614, comfortably above 541, so sieving up to about 614 finds it.

With the default values the calculator returns The 100th prime number = 541; Previous prime = 523; Next prime = 547; Estimate n(ln n + ln ln n) = 613.2.

Where Is This Calculation Used?

Questions like “what is the 10,001st prime?” are classic programming puzzles (the answer is 104743). The estimate shows how quickly primes thin out: the 1,000th prime is 7,919 and the 100,000th is 1,299,709.

Useful anchors: the 10th prime is 29, the 100th is 541, the 1,000th is 7,919, the 10,000th is 104,729 and the 100,000th is 1,299,709. The prime number theorem says the nth prime is about n ln n, and the average gap between consecutive primes near N is about ln N, so primes near one million are roughly 14 apart.

What are the most common mistakes with the Nth Prime Number Calculator?

  • Counting from 0; the first prime is 2, so n = 1 gives 2.
  • Using n ln n as an exact value rather than an estimate.
  • Counting 1 as the first prime.

What Is the Tested Example for the Default Values?

This example is computed by the same code that powers the calculator above, so you can compare it with your own numbers or a textbook answer.

Input: Position n100
The 100th prime number541
Previous prime523
Next prime547
Estimate n(ln n + ln ln n)613.2

Where Can You Verify These Formulas?

The definitions and formulas on this page follow standard references. Check them against these sources:

Built and maintained by S. Dilshan. Found a mistake? Email [email protected] with the page address.

Frequently Asked Questions

What is the 100th prime number?

541.

What is the 1000th prime number?

7919.

How accurate is n × ln n for the nth prime?

It underestimates noticeably for small n; the form n(ln n + ln ln n − 1) is closer, and the sieve gives the exact value.