Nth Prime Number Calculator

Find the nth prime number.

How it is calculated

A prime is a whole number greater than 1 whose only divisors are 1 and itself. To find the n-th prime the tool starts at 2 and checks each following integer by trial division: a number is prime if no integer from 2 up to its square root divides it evenly. Every prime found increases a counter, and the search stops when the counter reaches n. The position n is cut to a whole number and must be between 1 and 20,000; anything outside that range returns no result. Counting starts at 1, so n = 1 gives 2, n = 2 gives 3 and n = 3 gives 5. The result is the prime itself, not its position.

Worked example

Ask for n = 100. The list begins 2, 3, 5, 7, 11, 13 and continues, skipping every number that has a divisor other than 1 and itself. When the tool has counted 100 primes it stops at the last one, so the 100th prime is 541. The next one after it, 547, would be the 101st.

Try this example →

Common mistakes

  • Counting 1 as a prime; the first prime is 2.
  • Mixing up the position with the value: n = 100 asks for the 100th prime, not whether 100 is prime.
  • Using a zero-based index as programmers do; here the first prime is n = 1, not n = 0.
  • Entering a number above 20,000, which the tool does not accept.
  • Entering a decimal such as 10.7 and expecting rounding; the fraction is simply dropped.

About this calculator

This calculator finds the nth prime number — for example, the 1st prime is 2, the 2nd is 3, the 10th is 29, and so on — by sieving or testing successive integers for divisibility until it has counted enough primes. Prime numbers are whole numbers greater than 1 with exactly two divisors: 1 and themselves.

Math students use it to check number-theory homework, and programmers use it to verify their own prime-generating algorithms against a known answer.

Was this helpful?

You can pick up to 3 reactions.

Comments

  • Be the first to comment.

Popular calculators

All Calculators