题解 | #等差数列#
等差数列
https://www.nowcoder.com/practice/f792cb014ed0474fb8f53389e7d9c07f
#include <stdio.h> int main() { int n=0; int i=0; int j=2; int count=0; scanf("%d",&n); if(n>=1 && n<=1000)//判段n是否在正确范围 { for(i=0;i<n;i++)//前n项 { count+=j; j+=3;//公差为3 } } printf("%d",count); return 0; }