Is there a better way to find the nth prime?
조회 수: 14(최근 30일)
I want to find the value of the nth prime number. For example, the 10th prime number is 29. My code currently looks like this:
n = 1;
x = 10001;
n = n + 1;
I want to find the 10001st prime number (x = 10001), however this takes quite a while since the while loop executes for each natural number until 10001 primes have been counted. Is there a more efficient to write this code so that it doe's not take so long to execute? Thanks in advance.