Approximation might be a better approach.
Let r = 1 + x where x is small (and positive).
Then $$r^n \approx 1 + n x + \frac{n^2 - n}{2} x^2 $$, Solve $$P (1 + n x + \frac{n^2 - n}{2} x^2) + m ((1 + n x + \frac{n^2 - n}{2} x^2) - 1)/x - B = 0$$ for x, but call it $$x_0$$, discard the negative term. (when won't this work? When might we want the negative term?)
$$x_0 = \frac{\sqrt{n^2 (m (n-1) -2 P)^2 - 8 n (n -1) P (P - B)}-n (m (n-1)+2 P)}{2 n (n-1) P} $$
Call this the first estimate.
Now if $$x_0$$ is "good" we can improve it via Newton's method on $$f(x) = P (1+x)^n + m ((1+x)^n - 1)/x - B$$
$$x_1 = x_0 - f(x_0)/f'(x_0) = x_0 + \frac{x_0 (1 + x_0) (m + B x_0 - (1 + x_0)^n (m + P x_0))}{m (1 + x_0) + (1 + x_0)^n (n P x_0^2 + m ((n-1) x_0 - 1))}
\\ x_2 = x_1 - f(x_1)/f'(x_1) \\ \dots $$
Test: I have 1 million dollars, and I can save USD 500 a month, every month for the next 20 years. What rate do I need to reach a goal of 2 million dollars?
$$P = 10^6, B = 2 \times 10^6, m = 500, n = 240 $$
$$x_0 = \frac{\sqrt{414106089}-12717}{2868000} \approx 37/13903 $$ (which is a little high)
$$x_1 = x_0 + \frac{x_0 (1 + x_0) (m + B x_0 - (1 + x_0)^n (m + P x_0))}{m (1 + x_0) + (1 + x_0)^n (n P x_0^2 + m ((n-1) x_0 - 1))} \approx 2/789 $$ which is better.
$$x_2 \approx 0.002532872 \approx 1077/425209$$ which gives an error of only about USD 0.21 over 20 years.
The true value of x is approximately 0.0025328716115386 or 4256833/1680635126 but cannot be expressed exactly with a finite number of digits, so learning to work with approximations is good.