*因為1既不是質素也不是素數,所以從2開始*
下面給出了一種簡單的方法:
public class ceshi{
public static void main(String[] args){
int j;
for(int i=2; i <= 100; i++ ) {
for( j = 2; j <= i; j++ ) {
if( i % j == 0 ) {
break;
}
}
if( j >= i ) {
System.out.println(i);
}
}
}
}