Paste: payments
Author: | fred |
Mode: | factor |
Date: | Wed, 31 Dec 2008 20:37:08 |
Plain Text |
USING: io kernel math math.parser ;
IN: payments
: interest-rate
.02 12 / ;
: initial-balance
500 ;
: total-to-pay
587 ;
: number-of-payments
6 ;
: monthly-payment
total-to-pay number-of-payments / ;
: collect-interest
2dup * + ;
: payment
[ collect-interest ] dip [ - ] keep ;
: do-it
interest-rate initial-balance monthly-payment
number-of-payments [ payment ] times rot 2drop number>string print ;
Author: | fred |
Mode: | factor |
Date: | Wed, 31 Dec 2008 21:30:21 |
Plain Text |
USING: io kernel math math.parser ;
IN: payments
: interest-rate
.02 12 / ;
: initial-balance
500 ;
: total-to-pay
587 ;
: number-of-payments
6 ;
: monthly-payment
total-to-pay number-of-payments / ;
: collect-interest
dup interest-rate * + ;
: payment
collect-interest monthly-payment - ;
: do-it
initial-balance number-of-payments [ payment ] times
number>string print ;
MAIN: do-it
New Annotation