Present value

Dessign the function @valor_presente(I, r)@ that calculates the present
value of an investment I represented as a list of monthly payments and a
monthly interest rate r.

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: I = [5000, 5000, 5000, 45000]. The opportunity
cost is r = 0.05. The @valor_presente(I, r)@ is
5000 + 5000/(1.05) + 5000/(1.05)² + 45000/(1.05)³ = 53169.74408811143

In general, if the investment is given by I = [I₀, I₁, …, I_(n)], the
present value is $I[0] + \sum_{i=1}^{n}\dfrac{I[i]}{(1+r)^i}$

Sample session

Problem information

Author: InfBesos

Generation: 2026-01-25T19:23:14.698Z

© Jutge.org, 2006–2026.
https://jutge.org
