等差:
An = A1+(n-1)*d
将这个从An列到A2
An = A1+(n-1)*d
An-1 = A1+(n-1)*d
...
A2 = A1+(n-1)*d
A1 = A1+0*d
这些等式全部相加得到Sn=n*A1+ (n-1)*n/2
等比同样
An= A1 q^(n-1)
An-1=A1 *q^(n-2)
...
A2 =A1 *q
A1 =A1 *1
相加得Sn=A1(1+q+q^2+...+q^(n-1)) ...1
两边乘以q得
Sn*q = A1(q+q^2+...+q^n)...2
1-2得
(1-q)Sn = A1(1-q^n)
所以Sn=A1*(1-q^n)/(1-q)