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$$