# -------------------------------------------------------------------------------
# 计算年收益
# per_year_money 每年投资金额
# ratio 年化率
# year 总年数
# -------------------------------------------------------------------------------
def compute(per_year_money, ratio, year):
if year == 1:
return per_year_money * (1 + ratio)
else:
return (compute(per_year_money, ratio, year - 1) + per_year_money) * (1 + ratio)


# 每年投资金额
per_year_money = 600
# 年化率
ratio = 15 / 100
# 总年数
year = 10
for i in range(1, year + 1):
print('第{}年'.format(i), '{} 元'.format('%.2f' % (compute(per_year_money, ratio, i))))

相关文章:

  • 2022-01-14
  • 2022-02-21
  • 2022-12-23
  • 2021-09-12
  • 2021-12-10
  • 2021-04-12
  • 2022-12-23
  • 2021-07-20
猜你喜欢
  • 2022-12-23
  • 2021-07-29
  • 2021-05-27
  • 2022-12-23
  • 2022-12-23
  • 2021-11-25
相关资源
相似解决方案