Created
June 4, 2014 10:05
Revisions
-
freespace created this gist
Jun 4, 2014 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ # -*- 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