Calculate return on investment (ROI)
A tl;dr version of your question is:
Given constants $n, s, a, c$, can we find a closed form expression for $r$ that solves the equation:
$$ \sum_{i=1}^{n}\left ( \frac{a}{(1+r)^i}\right ) + \frac{s}{(1+r)^n} = c $$
Let us simplify. Let $t = \frac{1}{1 + r}$. Thus we have:
$$ \begin{align} a\sum_{i=1}^{n}t^i + st^n &= c \\ at\frac{\ 1-t^n}{1-t} + st^n &= c \\ at-at^{n+1} + st^n - st^{n+1} &= c - ct \\ at-(a+s)t^{n+1} + st^n &= c - ct \\ (a+s)t^{n+1} - st^n - (a+c)t + c &= 0 \\ \end{align} $$
Since you want to solve for $t$, you are essentially left with having to solve a polynomial of degree $n+1$. Unfortunately, if $n \geq 4$, you are completely out of luck in finding a closed form (thanks, Galois), but you could use a simple polynomial solver to quickly get solutions for $t$ and thus $r$.
Trying this out for your example in wolfram gives the solution $t = 0.90214$ which gives $x = \frac{1}{0.90214} - 1 = 0.10848$ and thus $x = 10.8$% solves the ROI for you example.
Since there might be multiple answers to polynomial, we can place bounds on valid answers. We need $0 < r < 1$ and so:
$$ \begin{align} 0 &< r < 1 \\ 1 &< 1 + r < 2 \\ \frac{1}{2} &< \frac{1}{1+r} < 1 \\ \frac{1}{2} &< t < 1 \end{align} $$
So any solution where $\frac{1}{2} < t < 1$ should be valid.