Code to print Nth prime number
问题 I have to print the Nth prime number. For example: 1st prime number is 2 2nd prime number is 3 . . 10th prime number is 29 and so on.... My algorithm is as follows: 1) Add 2 and 3 to stack. 2) If n <= Size of stack, get item at position n and output answer 3) Else, start from last element of stack, check if prime 4) To check for prime, divide from each element in stack. If remainder 0 for any element in stack, not a prime. Break loop 5) If Prime, add to stack 6) Search only odd numbers My