Artificial intelligent assistant

Mortgage calculating time for residual debt I have a mortgage for _C_ capital, with constant monthly payments, constant interest rate _i_ (and constant duration in year _D_ ). I would like to know after how much time I reimburse $r$ dollars. For example: For a $10$ year $3$% mortgage, with $100 000\$$ capital, after how much time I will have reimbursed $10 000\$$ (that is residual debt is $90 000\$$).

First assume annual payments. If each payment is $P$ then initial loan balance $C=\frac{P}{r}\left(1-\frac{1}{(1+i)^D}\right).$ If amount $r$ is reimbursed after $t$ years, then remaining loan balance $C-r=\frac{P}{r}\left(1-\frac{1}{(1+i)^{D-t}}\right)$. Taking ratio of the two equations, $1-\frac{r}{C}=\frac{1-\frac{1}{(1+i)^{D-t}}}{1-\frac{1}{(1+i)^{D}}}$ or $1+\frac{r}{C}\left((1+i)^{D}-1 \right)=(1+i)^{t}$ or $t=\frac{\ln\left(1+\frac{r}{C}\left((1+i)^{D}-1 \right) \right)}{\ln(1+i)}$.

If instalments are monthly, the number of payments and the interest rate are adjusted so the new formula for the number of months in which amount $r$ is reimbursed is

$t=\frac{\ln\left(1+\frac{r}{C}\left((1+\frac{i}{12})^{12\times D}-1 \right) \right)}{\ln(1+\frac{i}{12})}$

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy ab5e37fa233b5e250b6b98477d06b6f5