package shuzu_practice;

public class Practice4 {
/*
需求4:
输出1到100之内的素数及总个数
要求5个一行,数字之间使用空格隔开
不允许使用集合
*/
//4,6,8,9
//1,2,3,5,7,11
public static void main(String[] args) {
int i = 1;
int count = 0;
while (i <= 100) {
boolean flag = true;
if (i == 1) {
flag = false;
}
for (int j = 2; j < i; j++) {//i = 9; j = 1,2,3,4,5,6,7,8
if (i % j == 0) {
flag = false;
}
}
if (flag) {
if (count != 0 && count % 5 == 0) {
System.out.println();
}
System.out.print(i + "\t");
count++;
}
i++;
}
System.out.println();
System.out.println("素数的个数为" + count);
}

}