Skip to content

Instantly share code, notes, and snippets.

@colobas
Last active August 23, 2017 19:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save colobas/96524d6445fb613807ddec771e3614f0 to your computer and use it in GitHub Desktop.
Save colobas/96524d6445fb613807ddec771e3614f0 to your computer and use it in GitHub Desktop.
shower thoughts led me to this. correct me if I'm wrong
def retirement(s,y,n,r):
"""
Considering:
- You have 0 debt
- You make y per year (yearly income)
- You can save a fraction s per year
- You can invest at a r-1 yearly interest
This function returns the amount you have accumulated after n years.
This means you can live with (1-s)*y per year.
If:
retirements(s,y,n,r) * (r-1) >= (1-s)*y
Then:
After n years, you can retire and withdraw (1-s)*y from your savings per
year and you'll never run out of cash. I.e. you can keep the same spending
style, without working. You can set that to any other threshold, but this
is the most interesting one for me.
"""
return s * y * ((1+r)/2) * ((1-r**n)/(1-r))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment