Skip to content

Instantly share code, notes, and snippets.

@shinpei
Last active July 26, 2018 07:50
Show Gist options
  • Save shinpei/3bc31aa8d032fb99f6a56f35e017770f to your computer and use it in GitHub Desktop.
Save shinpei/3bc31aa8d032fb99f6a56f35e017770f to your computer and use it in GitHub Desktop.
calculate mortgage loan
years=25
amount = 45000000
bonus=300000
yearlyPay= 120000
def yearPay():
pay = 0
pay += bonus * 2
pay += yearlyPay * 12
return pay
interest = 1.35 / 100.0
leftover = amount
totalPay = 0
for i in range(1,years):
yp = yearPay()
leftover -= yp
totalPay += yp
leftover *= (1.0 + interest)
print "%dth year (%d): leftover = %d, totalPay= %d" % (i, 35 + i, leftover, totalPay)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment