package hello;
import java.util.Scanner;
public class Sushu {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in = new Scanner(System.in);
// int sum=in.nextInt();
for (int sum = 2; sum < 100; sum++) {
int prime = 1;
for (int i = 2; i < sum; i++) {
if (sum % i == 0) {
prime = 0;
break;
}
}
if (prime ==1 ) {
System.out.print(sum+" ");
}
else {
// System.out.println(sum+"不是素数");
}
}
}
}
输出结果为
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