Drew O. wrote:
John B. wrote:
I am trying to calculate a monthly payment for a loan in Ruby. Does
anyone know what the equivalent for math.pow in Java is for Ruby?
@monthlypayment = @principal*@rate/(1-Math.pow(1/(1+@rate),@payments))
Ive searched everywhere and cant seem to find anything.
I think this is what you’re looking for:
irb(main):001:0> 2 ** 1
irb(main):002:0> 2 ** 2
irb(main):003:0> 2 ** 3
irb(main):004:0> 2 ** 4
Yes this is what i am looking for. How do i then use it to calculate
amonthly payment, i have tried quite a few things but cant get the
syntax right: @monthlypayment =
So for the example below:
Suppose you finance your car with a loan of $12000 at a yearly interest
rate of 11% for four years, and make equal payments monthly. How much
will your payments have to be? Here the parameters are principal P =
$12000, interest rate i = 0.11, number of years n = 4, and number of
periods per year q = 12. Then the monthly car payment M is given by
M = Pi/[q(1-[1+(i/q)]-nq)],
Anyone done this before?