Sum of Geometric Sequence
S_n=\dfrac{a_1(1- r ^n)}{1- r }
or
Derivation 1
The formula for sum of a geometric sequence can be derived from the formula for general terms of a geometric sequence.
Using the formula for the n^{th} term of a geometric sequence,
a_n = a_1r^{n-1}
in which a_1 is the first tirm, r is the common ratio.
a_1 = a_1r^0
a_2 = a_1r^1
a_3 = a_1r^2
\dots
\begin{aligned} S_n&=a_1+a_2+\dots+ a_n \\ &=a_1(1+r^1+r^2+\dots+r^{n-1}) \\ &= \dfrac{a_1(r-1)(1+r^1+r^2+\dots+r^{n-1})}{r-1} \\ &= \dfrac{a_1(r+r^2+\dots+r^n-1 -r-r^2-\dots-r^{n-1})}{r-1} \\ &= \dfrac{a_1(1-r^n)}{1-r} \end{aligned}
Derivation 2
Using the recursive formula for a geometric sequence
a_n = a_{n-1}r
We get,
a_2 = a_1r
a_3 = a_2r
a_4 = a_3r
\dots
a_n = a_{n-1}r
Add the above equations,
a_2+a_3+a_4+\dots+a_n = (a_1+a_2+a_3+\dots+a_{n-1})r
S_n-a_1=(S_n-a_n)r
(1-r)S_n = a_1-a_nr
S_n = \dfrac{a_1-a_nr}{1-r}
\quad\space\space =\dfrac{a_1-a_1r^{n-1}r}{1-r}
\quad\space\space =\dfrac{a_1(1-r^n)}{1-r}