获取100以内的质子

public class TestZhiZi {

 //求质子100以内的
 public static void main(String[] args) {
  int a,b;
  for( a=1;a<=100;a++){
   for( b=2;b<=a;b++){
    if(a%b==0){
     break;
    }
   }
   if(a==b){
    System.out.print(a+"-");
   }
  }
 }
}

posted on 2011-06-29 14:45  Z.Y  阅读(349)  评论(0)    收藏  举报

导航