Dessign the function @valor_presente(I, r)@ that calculates the present value of an investment represented as a list of monthly payments and a monthly interest rate .
Example: John asks Paul to rent his vehicle for 3 months for a monthly payment of 5000 euros (the first payment is today). Once this time has passed, he will buy the vehicle for 45000 euros. John’s opportunity cost is 5% monthly. ¿Which is the present value of the project?
John’s investment is: . The opportunity cost is . The @valor_presente(I, r)@ is
In general, if the investment is given by , the present value is
>>> round(valor_presente([5000, 5000, 5000, 45000], 5), 2) 53169.74 >>> round(valor_presente([100, -50, 35], 7), 2) 83.84 >>> valor_presente([], 3) 0.0