nth Prime Number Java - Javatpoint
www.javatpoint.com › nth-prime-number-javaIn the while loop, execute the condition (c!=n). Initially, the variable c is 0 and counts the discovered prime numbers. Increment the variable i (initially 1) by 1 for the next number check. Check if the variable i is prime or not. If yes, increment the variable c by 1. Let's find the n th prime number through a Java program using a while loop.
python - Program to find the nth prime number - Stack Overflow
stackoverflow.com › questions › 21003381Feb 04, 2017 · Program to find nth Prime Number. def nth_Prime(num): Semi = num*num Res_1 = [True for i in range(Semi+1)] prime = 2 while prime*prime <= Semi: if Res_1[prime] == True: for i in range(prime*prime, Semi+1, prime): Res_1[i] = False prime += 1 Res_2 = [] for i in range(2, Semi+1): if Res_1[i]: Res_2.append(i) return Res_2[num-1] if __name__ == "__main__": num = int(input("Enter nth Number: ")) print(nth_Prime(num))