java每日一练
程序员文章站
2022-07-06 19:55:33
...
题目:求100之内的素数
public class Sushu {
public static void main(String[] args) {
boolean flag = false;
int count = 0;
for(int j=1;j<=100;j++){
for(int i=2;i<j;i++){
if(j%i==0){
flag = false;
break;
}else{
flag = true;
}
}
if(flag == true){
System.out.print(j+" ");
count++;
}
}
System.out.println("\n" + "Total "+ count + " prime number between 1 and 100");
}
}
上一篇: 聆听细节
下一篇: vue 笔记(持续更新)