|
package xiangmu;
|
|
|
|
public class Ceshi {
|
|
public static void main(String args[]) {
|
|
// 标志变量法判断质数
|
|
// 质数:只能被 1 和 自己 整除的正整数
|
|
int shuzi = 97;
|
|
int biaozhi = 0;
|
|
for(int i=2; i<shuzi; i++) {
|
|
if(shuzi % i == 0) {
|
|
biaozhi = 1;
|
|
break;
|
|
}
|
|
}
|
|
if(biaozhi == 0) {
|
|
System.out.println(shuzi + "是一个质数!");
|
|
}else {
|
|
System.out.println(shuzi + "不是质数!");
|
|
}
|
|
}
|
|
}
|