问题描述:
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 10001st prime number?
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 10001st prime number?
public static boolean IsPrime(long number) {
int begin = 2;
int end = (int) Math.sqrt(number) + 1;
for (int i = begin; i < end; i++) {
if (number % i == 0)
return false;
}
return true;
}
public static long count(int number){
long result = 1;
int n = 0;
long cur = 2;
while(n<number){
if(IsPrime(cur)){
result = cur;
n++;
}
cur++;
}
return result;
}