java-埃氏筛法求2-100内素数(质数)

// 埃氏筛法 找2-100以内素数
//2 3 5 7 11 13 17 19 23 29
//
//31 37 41 43 47 53 59 61 67 71
//
//73 79 83 89 97
public class Work18_3_15 {

public static void main(String[] args) {
int [] list = new int[99];
for (int i = 0; i < list.length; i++) {
list[i] = i+2;
}
for (int item:
list) {
if (item2){
System.out.print(item+"\t");
}else {
if (item%2
0)continue;
else {
if (item3) System.out.print(item+"\t");
else {
if (item%3
0)continue;
else {
if (item5) System.out.print(item+"\t");
else {
if (item%5
0)continue;
else {
if (item7) System.out.print(item+"\t");
else {
if (item%7
0)continue;
else {
System.out.print(item+"\t");
}
}
}
}
}
}
}
}
}
}
}

posted @ 2022-03-22 12:27  花痴dy  阅读(189)  评论(0)    收藏  举报