public class Test1 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int line = 1;
for (int i = 100; i < 1000; i++) {
if (prime(i)) {
if (line % 11 != 0) {
System.out.print(i + "\t");
line++;
} else {
System.out.println();
line++;
}
}
}
}
public static boolean prime(int n) {
boolean flag = false;
int num = 2;
while (true) {
if (n % num == 0) {
break;
} else if (num < Math.sqrt(n)) {
num++;
} else {
flag = true;
break;
}
}
return flag;
}
}
|