------ Solution ------- -------------------------------------
k + + should be i + +?
------ Solution ---------------------------------------- ----
your loop i
------ Solution ---------------------------------------- ----
public class LX2 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int i,k,count=0;
for(k=101;k<=200;k++){
for(i=2;i<Math.sqrt(k);i++){
if(k%i==0){
break;
}
}
if(i>Math.sqrt(k)){
count++;
}
}
System.out.println("素数个数:"+count);
}
}
------ For reference only ---------------------------- -----------
Why can not produce results, be sure to use Boolean expressions ?
没有评论:
发表评论