Posted on April 15, 2006 at 11:44 pm

I think this is as small as the amortization program can get without losing functionality. If you can make it smaller, please let me know about it.

def a(p,i,m)j=i/1200;Array.new(m){|n|p=(b=p-k=p*(j/(1-(1+j)**-m))-q=p*j);[n+1,b,q,k]}end

You can still use it the same way. To print a full amortization schedule, for $200,000 at 7.5% interest over 360 months:

puts "month,balance,interest,principle"
a(200000, 7.5, 360).each {|p|printf "%.2f,%.2f,%.2f\n",*p}
Leave a comment

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>