for($i = 100;$i<=200;$i++){
if($i%3 ==0 and $i%5==0){
echo $i.'
';
}
}
?>
这是PHP的,因为你没说你需要用啥语言写
java实现的:
其他语言解决思路类似:
public class Test2 {
/**
* @param args
*/
public void test1(){
int count=0;
for(int i=100;i<=200;i++){
if((i%3==0) && (i%5==0)){
count++;
System.out.println(i);
}
}
System.out.println("共有:"+count+"个");
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Test2 test2 =new Test2();
test2.test1();
}
}
int n=0;//记录个数
for(int a=100;a<201;a++)
{
if(a%3==0&&a%5==0)
{
printf(“%d\n”,a);
n++;
}
}