Skip to content

Instantly share code, notes, and snippets.

@aambrioso1
Created September 8, 2019 13:00
Show Gist options
  • Save aambrioso1/bd60759bbfe9a588abc47c1ab304a9db to your computer and use it in GitHub Desktop.
Save aambrioso1/bd60759bbfe9a588abc47c1ab304a9db to your computer and use it in GitHub Desktop.
apr.py
"""
0 1,500.00 0.00
1 1,308.52 44.18
2 1,210.59 64.08
3 1,111.17 82.49
4 1,010.24 99.39
5 907.77 114.75
6 803.75 128.56
7 698.14 140.78
8 590.93 151.40
9 482.09 160.39
10 371.59 167.72
11 259.41 173.37
12 145.53 177.32
13 29.91 179.53
14 0 179.98
"""
from decimal import *
bal = Decimal('1500')
r =Decimal('0.1825')
pay = Decimal('117.83')
tot_int= Decimal('0')
while(bal > 0):
print(round(bal,2), round(tot_int,2))
int = bal * r / 12
if bal < 117.83:
last_bal = bal
last_tot_int = tot_int
bal = bal - pay + int
tot_int += int
int = last_bal * r/12
last_tot_int += int
bal -= bal
print(round(bal,2),round(last_tot_int,2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment