Find the common ratio of the geometric progression Given:
Geometric progression Sum = $S$
First Term = $a$
number of terms = $N + 1$
$$a + aq + aq^2 + ... + aq^N = S$$
So, we need to solve this equation:
$$\sum_{i = 0}^N{q^i} = S/a$$
I need a formula to calculate common ratio $q$.
I think this is hard to do, as we need to solve equation of $N$th degree, but this is kind of a special equation, so, maybe there could be a good solution.
Thanks in advance.
 A: The $N$-th partial sum is
$$
S_N = a \sum_{k=0}^N q^k = \left\{ 
\begin{align}
a\frac{q^{N+1} - 1}{q - 1}, \quad q \ne 1 \\
a (N + 1), \quad q = 1
\end{align}\right.
$$
So given a problem instance $(a, S, N)$ the first step is to treat the case $a = 0$ which implies $S=0$. In this case any number will work as value for $q$. For the following we assume $a \ne 0$.
If $a \ne 0$ and $S = 0$ there is no solution $q$. For the following we assume $S \ne 0$ as well.
Next thing would be to check if
$$
S = a (N+1)
$$ 
in this case $q=1$ is the solution. For the following we assume $q \ne 1$ too, having $a \ne 0$, $S \ne 0$, $q \ne 1$ as constraints.
If we still got the case $S = a$, then this would require $q = q^{N + 1}$, which would have $q = 0$ as solution and additionally $q = -1$ in case of odd $N$. 
Looking for Fixed Points
One method would be to search for a fixed point $q^{*}$ for
$$
f(q) = \frac{a}{S} q^{N+1} + 1 - \frac{a}{S}
$$
which fullfills $f(q^{*}) = q^{*}$.
This version of the original problem is easier to reason with, because one can treat this as the geometric problem of the graph of $f(q) = u \, q^n + v$ (two cases for even and odd exponents $n$, two cases for positive or negative factor $u$) crossing the diagonal line $\mbox{id}(q) = q$. 
For odd $N$ the exponent in $f$ is even, we got some parabolic graph which has zero, one or two crossings with $\mbox{id}$ and thus that many solutions.
For even $N$ the exponent is $f$ is odd and for $N \ge 2$ there might be even a third solution.
A: If the number of terms is $N + 1$ the common ratio satisfies
$S=\frac{a(q^{N+1}-1)}{q-1}$
Your sum has $N+1$ terms.
