求1-1000所有奇数的和

package com.itemma;
/*
 在前一个程序的基础之上,计算1~1000所有奇数的和。
  运算符 += 就是专门完成追加的。,
*/
import java.util.Scanner;
public class Complex02 {
    public static void main(String[] args) {
        int sum = 0;
        for(int number = 1;number<=1000;number++){
            if(number %2 == 0){
                continue;
            }else{
                sum += number;

            }

        }
        System.out.println(sum);

    }

        }


C:\Software\Java\jdk-17\bin\java.exe "-javaagent:E:\IntelliJ IDEA Community Edition 2021.3\lib\idea_rt.jar=62429:E:\IntelliJ IDEA Community Edition 2021.3\bin" -Dfile.encoding=UTF-8 -classpath "E:\IntelliJ IDEA Community Edition 2021.3\IDEA Studying\out\production\IDEA Studying" com.itemma.Complex02
250000

Process finished with exit code 0
上一篇:Axure RP 8.1.0.3388授权码/注册码,亲测有效长久激活


下一篇:2021-11-15