//System.out.print(2/2);
for (int i = 1; i < 100; i++) {
//System.out.print(i+", ");
boolean a=false;
for (int j = 2; j < 10; j++) {
if (i/j > 0 && i%j == 0 && i != j){
//System.out.println(i);
a = true;
break;
}
}
if (!a)
System.out.print(i+", ");
}
其实这道题主要是求100以内的质数,所以不能被10以内整除的就质数了,没有必要除以100以内每个数,我也给出算法
1, 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,