Finding the first term of a geometric series by the sum and $n$ I have the following exponential series:
$$S = ar^0 + ar^1 + ar^2 + \cdots + ar^n$$
I know $S$, $r$ and $n$. How do I find $a$?
I actually need this done by a script so all "crazy" methods like doing an operation $n$ times are ok.

As Raskolnikov points out this is a geometric series. Sum is given by $$S = a \cdot \frac{r^{n+1}-1}{r-1}$$
Substitute the value of $S,r,n$ to get $a$
