Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# -*- coding: utf-8 -*-
"""
Created on Sat May 31 11:35:04 2014
@author: freespace
"""
def repayment_pc(earning):
thresholds = [ [59421, 0.04],
[65497, 0.045],
[68939, 0.05],
[74105, 0.055],
[80257, 0.06],
[84481, 0.065],
[92970, 0.07],
[99069, 0.075],
]
for upperthres, pc in thresholds:
if earning < upperthres:
return pc
# this is the max repayment rate
return 0.08
debt=50e3
interest = 0.06
earning = 60e3
max_earning = 65e3
yearly_raise = 0.03
years = 0
max_years= 100
while debt > 0:
payment = repayment_pc(earning) * earning
debt -= payment
debt *= (1+interest)
earning *= (1+yearly_raise)
earning = min(earning, max_earning)
years += 1
print years, debt, interest, earning, payment
if years > max_years:
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment