Mortgage formula I'm using:
$$M = P \left(i + \frac{i}{(1+i)^n-1}\right)$$
where $M =$ payment amount, $P =$ principle balance, $i =$ term interest rate, and $n =$ number of terms.
But now I'm trying to solve for $n$ and get stuck trying to fix the exponent. I think it has to do with logarithms and I guess I slept through those classes. The farthest I can get is:
$$(1+i)^n = \frac{i}{\frac{M}{P}-1}+1$$
If you take the natural logarithm (ln) of both sides, you get: $$n \ln (1+i) = \ln \left( \frac{i}{ \frac{M}{P}-1} + 1 \right) $$
This follows from the law $\ln(a^b) = b \ln(a)$. Then you are one step away from isolating $n$.