public class test
{
public static void main(String[] args)
{
for(int i = 1;i <= 500;i++)
{
if(i%3 == 0 && i%5 == 0)
System.out.println(i);
}
}
}
或者,如果你只是想输出,也可以用下面的方法:
public class test
{
public static void main(String[] args)
{
int i = 15;
while( i <= 500)
{
System.out.println(i);
i += 15;
}
}
}
class a
{
public static void main(String[] args)
{
int i;
for(i=1;i<=500;i++)
{
if(i%3==0 && i%5==0)
System.out.println(i);
}
}
}
public class Test {
public static void main(String[] args) {
for(int i=1;i<=500;i++)if(((i % 3)==0) && ((i%5)==0))System.out.println(i);
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package testgraphics;
/**
*
* @author zz
*/
public class Test {
public static void main(String[] args) {
for(int i=1;i<=500;i++)if(((i % 3)==0) && ((i%5)==0))System.out.println(i);
}
}
for(int p=0;p<501;p++){
if(p%3==0&p%5==0){
System.out.println(p);
}
}