首页 > 代码库 > 等比数列求和

等比数列求和

如果公比为2,有k个元素:
Sk = 20+21+22+23+...+2k-1

2(Sk) = 2(20+21+22+23+...+2k-1)

        = 21+22+23+...+2k-1+2k

得:

Sk = 2(S1) - S1 = 2k-20 = 2k-1

 

通用推导:

设公比为q

Sn = a1+a2+a3+...+an

    = a1 + a1q + a1q2+a1q3+...+a1qn-1

qSn = a1q + a1q2+a1q3+...+a1qn-1+a1qn

qSn- Sn = a1qn-a1

Sn = a1(qn-1)/(q-1)

 

再回头让q=2,a1=1,带入翻过来验证:

Sn = 2n-1

等比数列求和