题解 | #牛牛学数列4#
牛牛学数列4
https://ac.nowcoder.com/acm/problem/22159
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int res = 0; //记录第n个数
int sum = 0; //记录n个数的和
for(int i = 1; i <= n; i++){
res += i;
sum += res;
}
System.out.println(sum);
}
}