Given that first term = $a$.
$\text{S}=$ sum to infinity of a $\text{G.P} =\dfrac{a}{(1-r)}$
$\Rightarrow r=1-\dfrac{a}{\text{S}}$
$\Rightarrow \text{S}_n=\dfrac{a(1-r^n)}{(1-r)}$
$\Rightarrow \text{S}_n=\text{S}(1-r^n)$
$\Rightarrow \text{S}_n=\text{S}\left[1-\left(1-\dfrac{a}{\text{S}}\right)^n\right]$