python-CFA-計算實現理財目標需要準備的現金流期數

An individual wants to be able to spend €80,000 per year for an anticipated 25 years in retirement. To fund this retirement account, he will make annual deposits of €6,608 at the end of each of his working years. He can earn 6% compounded annually on all investments. The minimum number of deposits that are needed to reach his retirement goal is closest to:

def calculate_needed_num(deposit_money,cost_money,cost_years,return_rate):
    count=1
    while True:
        net_money=0
        for i in range(count):
            net_money=net_money*(1+return_rate)+deposit_money
        for i in range(25):
            net_money=(net_money-cost_money)*(1+return_rate)
        if net_money>=0:
            return count
        
        count+=1

 calculate_needed_num(6608,80000,25,0.06)

得到41

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章