1-100求和,偶数求和,循环输出100能被3或5整除的数

public class guo {
public static void main(String[] args) {
int a=0;
for (int i = 1; i <=100; i++) {
a+=i;
}
System.out.println(a);
}
}

public class guo {
public static void main(String[] args) {
int a=0;
for (int i = 2; i <=100; i+=2) {
a+=i;
}
System.out.println(a);
}
}

public class guo {
public static void main(String[] args) {
for(int i=1;i<=100;i++)
{
if(i%3==0&&i%5==0)
{
System.out.print(i);
System.out.print(” “);
}
}
}
}

你可能感兴趣的:(java基础)