# NOT RUN {
#
# Value of a principle after yrs years at 5% return, compounding monthly.
fin_compound_interest(principal = 5000, interest = 0.05, yrs = 10)
# annual compounding
fin_compound_interest(principal = 5000, interest = 0.05, yrs = 10, n=1)
#
# Value of periodic deposit of $100/yr after 10 years at rate 7% return.
fin_compound_interest(deposits = 100, interest = 0.07, yrs = 10, n = 12)
#
# Value of principal + deposit of $100/yr after 10 years at rate 7% return.
fin_compound_interest(principal = 20000, deposits = 100, interest = 0.07, yrs = 10)
#
fin_compound_interest(deposits = 20e3, interest = 0.07, yrs = 10, n=1)
# manually
sum(20e3*(1.07^(10:1))) # 295672
# $10,000 invested at the end of each year for 5 years at 6%
fin_compound_interest(deposits = 10e3, interest = 0.06, yrs = 5, n=1, when= "end")
# }
Run the code above in your browser using DataLab