public static void main(String[] args) { int sum=0; for (int i=0; i<=100;i++){ if(i%3!=0){ sum +=i; } } System.out.println("1~100之间不能被3整除的数之和是:"+sum); }
03-22
1260
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
public static void main(String[] args) { int sum=0; for (int i=0; i<=100;i++){ if(i%3!=0){ sum +=i; } } System.out.println("1~100之间不能被3整除的数之和是:"+sum); }