Last active
August 23, 2017 19:15
-
-
Save colobas/96524d6445fb613807ddec771e3614f0 to your computer and use it in GitHub Desktop.
shower thoughts led me to this. correct me if I'm wrong
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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