转自 https://zxi.mytechroad.com/blog/sp/amortized-analysis/
证明:1+2+4+8+...+n = 2n-1
a1=1,项数k=log2(n)+1
=等比数列求和=a1*(q^n-1)/(q-1)
①:Sn=a1+a2+...+an
②:q*Sn=q*a1+q*a2+...+q*an = a2+a3+...+an+q*an
①-②:(1-q)*Sn=(a1-q*an)=(a1-q*a1*q^(n-1))=a1-a1*q^n
-> Sn=a1(1-q^n)/(1-q)
所以本为题的和
= 1*(1-2^(log2(n)+1))/(1-2)
= 2^log2(n) * 2^1 - 1
= n * 2 -1
= 2n-1