# Sum of a Geometric Series

What is the sum of the following geometric series?
$\sum_{i=0}^{k}a^i=1+a+a^2+…+a^k$
We will frequently need a simple formula for this finite series. It is called a geometric series because each term is related by a multiple to the previous one. If each term was related by a fixed difference, it would be called an arithmetic series; but that’s for another day.
Let us define the sum as $$S$$. Then writing the equation for $$S$$ and $$aS$$ with some clever alignment:

\begin{array}{rrrccc}
S=&1&+a&+a^2&+…&+a^k \\
aS=&&a&+a^2&+…&+a^k&+a^{k+1}
\end{array}
Subtract the equations
$S(1-a)=1-a^{k+1}$
or
\begin{align}
S=
\begin{cases}
\frac{1-a^{k+1}}{1-a} &a \neq 1 \\
k+1 &\text{otherwise}
\end{cases}
\end{align}
where we have to be careful to divide by $$1-a$$ only if $$a\neq 1$$, and the answer for $$a=1$$ is determined by inspection.
Q.E.D.