求100以内的素数

来源:互联网 发布:九宫格照片软件 编辑:程序博客网 时间:2024/04/19 23:20
 public static void main(String[] args) {
  int count=0;
  System.out.print("素数如下:");
  for(int i=2;i<100;i++){
   count=0;
   for(int j=2;j<i;j++){
    if(i%j==0){
     count++;
     break;
    }
   }
   
   if(count==0){
    System.out.print(i+" ");
   }
  }
 }
原创粉丝点击