def npv(discount, cashflows)
      total = 0

      cashflows.each_with_index do |cashflow, index|
        total += (cashflow.to_f / (1 + discount.to_f) ** (index + 1))
      end

      total
    end
def npv(discount, cashflows)
      total = 0

      cashflows.each_with_index do |cashflow, index|
        total += (cashflow.to_f / (1 + discount.to_f) ** (index + 1))
      end

      total
    end
Calculates the net present value of an investment based on a
 series of periodic cash flows and a discount rate.

 @param discount [Float] The discount rate of the investment over one period
 @param cashflows [Array] The first future cash flow + additional future cash flows

 @return [Float]

 @example
   Exonio.npv(0.281, [-100, 39, 59, 55, 20]) # ==> -0.00661872883563408