By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.
What is the 10 001st prime number?
public class BigPrime {
public static void main(String args[]){
int j=0;
for(long i=2;i<2000000000;i++){
if(isPrime(i)){
j++;
if(j==10001){
System.out.println(i);
}
}
}
}
public static boolean isPrime(long n){
for(int i = 2; i * i <= n; i++){
if(n % i == 0)
return false;
}
return true;
}
}
Answer:
| 104743 |