Solved
How to find the Nth prime number
Posted on 2007-11-28
I need to find the Nth prime number. I.E. if the input is 3 it should return 5 because the first three prime numbers are 2,3, and 5. 4 should return 7 and so on. I just need an algorithm or some pseudocode here right now because i'm writing this in assembler. So far this is what i have.
for(divisor = 2; divisor < num; divis++)
{
if((num mod divisor) == 0)
num is not prime
break out of the loop
}
if((num - divisor) == 1)
num is a prime
//if num - divisor == 1 that means that it made it the whole way through the for loop without being broken out of the loop and there was no number that would divide the number therefore it is prime.