Compute how much you will have to pay per month for 10, 15, 20, 25, or 30 years if you borrow NT$5,000,000, 10,000,000, or 15,000,000 from a bank that charges you 2%, 5%, or 7% for the monthly interest rate.

制定公式

dta <- function(L,r,M){
 P <- L*(r/(1-(1+r)^(-M)))
return(P)}

固定r=0.02,將三種金額,分別帶入10, 15, 20, 25, 30年(已經換算月數),金額四捨五入

ceiling(dta(c(5000000, 10000000, 15000000),
    0.02, 
    c(rep(120,3), rep(180,3), rep(240,3), rep(300,3), rep(360,3))))
##  [1] 110241 220481 330722 102914 205828 308742 100871 201741 302612 100264
## [11] 200528 300792 100081 200161 300241

同上,固定r=0.05

ceiling(dta(c(5000000, 10000000, 15000000),
    0.05, 
    c(rep(120,3), rep(180,3), rep(240,3), rep(300,3), rep(360,3))))
##  [1] 250719 501438 752156 250039 500077 750116 250003 500005 750007 250001
## [11] 500001 750001 250001 500001 750001

同上,固定r=0.07

ceiling(dta(c(5000000, 10000000, 15000000),
    0.07, 
    c(rep(120,3), rep(180,3), rep(240,3), rep(300,3), rep(360,3))))
##  [1]  350105  700209 1050313  350002  700004 1050006  350001  700001 1050001
## [10]  350001  700001 1050001  350001  700001 1050001