lib/exonio/financial.rb
def pmt(rate, nper, pv, fv = 0, end_or_beginning = 0)
      temp = (1 + rate) ** nper
      fact = (1 + rate * end_or_beginning) * (temp - 1) / rate

      -(fv + pv * temp) / fact
    end
def pmt(rate, nper, pv, fv = 0, end_or_beginning = 0)
      temp = (1 + rate) ** nper
      fact = (1 + rate * end_or_beginning) * (temp - 1) / rate

      -(fv + pv * temp) / fact
    end
Calculates the periodic payment for an annuity investment based on
 constant-amount periodic payments and a constant interest rate.

 @param rate [Float] The interest rate as decimal (not per cent) per period
 @param nper [Integer] The number of payments to be made (number of periods)
 @param pv [Float] The present value of the annuity
 @param fv [Float] The future value remaining after the final payment has been made
 @param end_or_begining [Integer] Whether payments are due at the end (0) or
   beggining (1) of each period

 @return [Float]

 @example
   Exonio.pmt(0.075/12, 12*15, 200_000) # ==> -1854.0247200054619