单畉计 (arithmetic series)
单畉计计厩﹚竡
璝兜 aそ畉 d兜计 n玥玡 n 兜单畉计㎝
sn= a + (a+d) + (a+2d) + ... + (a+(n-1)d)
ㄤい璝 a+(n-1)*d = an玥
sn-1 = a1 + a2 + a3 + ... + an-1
sn = sn-1 + an
璝患癹ㄧ计 sum(n) = sn = a1 + a2 + a3 + ... + an
玥 sum(n) = sum(n-1) + an
玥ㄧ计砞璸よΑ
1.  a 籔 d ぃ穦э跑祘Αよ獽┦砞 a 籔 d 办┦跑计
2.患癹ㄢ璶
    A.sum(n) 籔 sum(n-1) 闽玒 sum(n) = a+(n-1)*d + sum(n-1)
    B.sum(1) = 1

癹伴
患癹

#include <stdio.h>
#include <stdlib.h>
int a,d;

int main(){
    int i, n, s=0;
    scanf("%d %d %d",&a, &d, &n);
    for(i=1; i<=n; i++)
        s+=a+(i-1)*d;
    printf("s=%d\n",s);
    return(0);
}

#include <stdio.h>
#include <stdlib.h>
int a,d; //办┦跑计兜 a,そ畉 d

int sum(int n){
    if(n==1)
        return(a);
    else
        return(a+(n-1)*d+sum(n-1));
}

int main(){
    int s, n;
    scanf("%d %d %d",&a, &d, &n);
    s=sum(n);
    printf("s=%d\n", s);
    return(0);
}