Quick actions

cmd+k|ctrl+k

Navigation

Languages

Savings Calculator w/ Compound Interest

Snippet info

Language

Python

Visibility

public

Author

itjustmightbejack

Created

2023-05-02T10:08:50.471297Z

Updated

2023-05-02T11:45:04.91231Z

# Constant Savings throughout entire year

# function is of the form constant_savings(A,B,C,D,E)
# A is how much you save (either per year or per month)
# B is how long you save this much per year/month for
# C is how long you let the money accumulate value before pulling it out
# D is the yearly return rate (i.e. for a 10% return rate, input 10)
# E is False if A is how much you save per year and True if A A is how much you save per month
#   NOTE: E must be written exactly as True or False with the capital for it to work



def constant_savings(amount_saved , years_spent_saving , years_left_alone , yearly_return_rate , monthly):
    
    net_worth = 0
    mul = 1
    if monthly == True:
        mul = 12
        
    for i in range(years_spent_saving):
        net_worth *= (1+(yearly_return_rate/100))
        net_worth += (amount_saved*mul)
    
    retirement_fund = net_worth*((1+(yearly_return_rate/100))**years_left_alone)
    
    retirement_fund /= 1000000
    
    
    return "£"+str(round(retirement_fund,1))+" million"
    
print(constant_savings(500,10,35,7,True))

print(constant_savings(1000,10,25,7,True))

print(constant_savings(2000,10,15,7,True))

print(constant_savings(4000,10,5,7,True))




# Noteworthy Results:

# With a 10% return rate (avg yearly return of S&P500, not adjusted for inflation)
# Saving 500/mo in 20s = 1300/month in 30s = 3400/mo in 40s = 8700/mo in 50s if you pull it all out at 65
# Saving 500/mo in your 20s alone gives you 2.7 million to retire on when you're 65

# With a 7% return rate (avg yearly return of S&P500, adjusted for inflation)
# 500/mo in 20s = 1000/mo in 30s = 2000/mo in your 40s = 4000/mo in your 50s if you pull it all out at 65
# Saving 500/mo in your 20s alone gives you 0.9 million to retire on when you're 65



        
INFO