/**
*
* @author liu
*
*/
public class Main{
public static void main(String[] args) {
final int MAX = 3000500;
int p[] = new int[MAX];
int pNum = 0;
int f[] = new int[MAX];
for (int i = 2; i < MAX; i++) {
if (f[i] == 0) {
p[pNum++] = i;
}
for (int j = 0; j < pNum && p[j] * i < MAX; j++) {
f[p[j] * i] = 1;
if ((i % p[j]) == 0)
break;
}
}
}
}
线性筛选素数
最新推荐文章于 2022-04-11 11:06:55 发布