# Solve for n for loan amortization

Can someone help with rearranging the following formula to find n with explanation?

$$PMT = \frac{PV}{\frac{1}{r} \cdot(1- \frac{1}{(1+r)^{n}})}$$

You use the notion of a logarithm to extract exponent, since $\log(a^n)=n\log(a)$. First we wish to isolate the $(1+r)^{-n}$ algebraically to get
$$1-\frac{rPV}{PMT}=(1+r)^{-n}$$ and then we apply the logarithm to get
$$\log\left(1-\frac{rPV}{PMT}\right)=-n\log(1+r)$$ and so we wind up at
$$n=-\frac{\log\left(1-\frac{rPV}{PMT}\right)}{\log(1+r)}$$