TITLE: Calculating sum of consecutive powers of a number
QUESTION [34 upvotes]: Here is my problem, I want to compute the $$\sum_{i=0}^n P^i : P\in ℤ_{>1}$$
I know I can implement it using an easy recursive function, but since I want to use the formula in a spreadsheet, is there a better approach to this?
Thanks.

REPLY [8 votes]: We have 
$$\begin{array}{l}
S_n&=1+P+P^2+P^3+\cdots+P^n\\
P\cdot S_n&=0+P+P^2+P^3+\cdots+P^n+P^{n+1}
\end{array}$$
Subtracting two above equations gives
$$
S_n-P\cdot S_n=1-P^{n+1}
$$
divide by $S_n$
$$
1-P=\dfrac{1-P^{n+1}}{S_n}\\
S_n=\dfrac{1-P^{n+1}}{1-P}
$$