标签:prime 开始 == break ati pre while return prim
public static int NthPrime(int n) {
int i = 2, j = 1;//i从2开始,j是除数,从1开始算
while (true) {
j = j + 1;
if (j > i / j) {
n--;
if (n == 0)
break;
j = 1;
}
if (i % j == 0) {
i++;
j = 1;
}
}
return i;
}
标签:prime 开始 == break ati pre while return prim
原文地址:https://www.cnblogs.com/MarkLeeBYR/p/9772991.html