S = 1 + 2q + 3q2 + ....+ (n+1)qn
q.S = q + 2q2 + 3q3 + ...+ (n+1)qn+1
=> S - q.S = 1 + q + q2 + q3 + ...+ qn - (n+1)qn+1
=> (1 - q).S = (1 + q + q2 + q3 + ...+ qn) - (n+1)qn+1
Tính A = 1 + q + q2 + q3 + ...+ qn => q.A = q + q2 + ...+ qn+ 1
=> A - q.A = 1 - qn+1 => A = (1 - qn+1)/(1-q)
Vậy (1-q).S = (1 - qn+1)/(1-q) - (n+1)qn+1 => S = (1 - qn+1)/(1-q)2 - (n+1)qn+1/ (1 - q)