public class A {
/**
* @param args
*/
public static void main(String[] args) {
for(int i = 50;i < 100; i++){
boolean isPrime = true;
for(int j = 2; j <= Math.sqrt(i); j++){
if(i % j == 0){
isPrime = false;
break;
}
}
if(isPrime){
System.out.print(i + ", ");
}
}
}
}
-----------testing
53, 59, 61, 67, 71, 73, 79, 83, 89, 97,
public class SuShu {
public static void main(String[] args) {
int n = 0;
a:for(int i=50;i<=100;i++){
for(int j=2;j n = i%j;
if(n==0)continue a;
}
System.out.println(i);
}
楼上正解,我就不班门弄斧了