题解 | #牛牛学数列4#
牛牛学数列4
https://www.nowcoder.com/practice/586b114f52034688879342ba45779081
#include <stdio.h> int main() { int n = 0; scanf("%d", &n); int i = 0; int sum = 0; for (i = 1; i <= n; i++) { sum += (1 + i) * i / 2;//等差数列前n项和公式 } printf("%d\n", sum); return 0; }