Tip: Click lines to highlight, hold ctrl/cmd to multi-select

http://codedumper.com/iwudu (27-May @ 03:38)

Syntax Highlighted Code

  1. #!/usr/bin/python
  2.  
  3. def amort(cost, interest, term, pmt):
  4.     mint = (1 + interest) ** (1.0/12)
  5.     for i in range(term):
  6.         for j in range(12):
  7.             cost *= mint
  8.             cost -= pmt
  9.     return cost
  10.  
  11. def findpmt(cost, interest, term):
  12.     ub = cost
  13.     lb = 0
  14.     test = cost / 2
  15.     bal = amort(cost, interest, term, test)
  16.     while abs(bal) > 1000:
  17.         if bal > 0:
  18.             lb = test
  19.         else:
  20.             ub = test
  21.         test = (lb + ub)/2
  22.         bal = amort(cost, interest, term, test)
  23.     return test
  24.  
  25. def ira(down, pmt, interest, term):
  26.     mint = (1 + interest) ** (1.0/12)
  27.     for i in range(term):
  28.         for j in range(12):
  29.             down += pmt
  30.             down *= mint
  31.     return down
  32.  
  33.  

Plain Code

#!/usr/bin/python

def amort(cost, interest, term, pmt):
    mint = (1 + interest) ** (1.0/12)
    for i in range(term):
        for j in range(12):
            cost *= mint
            cost -= pmt
    return cost

def findpmt(cost, interest, term):
    ub = cost
    lb = 0
    test = cost / 2
    bal = amort(cost, interest, term, test)
    while abs(bal) > 1000:
        if bal > 0:
            lb = test
        else:
            ub = test
        test = (lb + ub)/2
        bal = amort(cost, interest, term, test)
    return test

def ira(down, pmt, interest, term):
    mint = (1 + interest) ** (1.0/12)
    for i in range(term):
        for j in range(12):
            down += pmt
            down *= mint
    return down

Permalink: http://codedumper.com/iwudu