参考代码:
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int res = 0; for(int i = 1; i <= n; i++) res += i; System.out.println(res); } }
0.0分
5 人评分