Calcolatore di valore futuro
Calcola il valore futuro di investimenti con interesse composto.
Domande Frequenti
Implementazione del Codice
def future_value(pv, rate, periods):
"""Future value of a lump sum (FV = PV * (1+r)^n)."""
return round(pv * ((1 + rate) ** periods), 2)
def future_value_with_contributions(pv, pmt, rate, periods):
"""FV with regular contributions (annuity)."""
fv_lump = pv * ((1 + rate) ** periods)
if rate == 0:
fv_annuity = pmt * periods
else:
fv_annuity = pmt * (((1 + rate) ** periods - 1) / rate)
return round(fv_lump + fv_annuity, 2)
def real_future_value(nominal_fv, inflation_rate, years):
"""Inflation-adjusted (real) future value."""
return round(nominal_fv / ((1 + inflation_rate) ** years), 2)
# Example: $10,000 at 7%/yr for 20 years, adding $200/month
monthly_rate = 0.07 / 12
periods = 20 * 12
fv = future_value_with_contributions(10000, 200, monthly_rate, periods)
print(f"Nominal FV: ${fv:,.2f}")
print(f"Real FV (3% inflation): ${real_future_value(fv, 0.03, 20):,.2f}")Comments & Feedback
Comments are powered by Giscus. Sign in with GitHub to leave a comment.