

function calcPaymentS(m,n,R,principal) //PaymentCalc ( [number of periods per year] ,[  total number of periods ], [ annual interest rate  ] ,[ present value of an annuity ])
{
	/*
		m = number of periods per year. For instance, if you are For
		instance, if you are making payments monthly then this number is 12.

		n = total number of periods. For instance, if you are
		compounding monthly for 5 years, this number would be 60 (12 months
		x 5 years).

		R = annual interest rate (represented as a decimal, 8% = .08)

		pmt = first or re-occuring payment or receipt (this number cannot
		vary for differing cash flows)

		principal = present value of an annuity, or current principal of a
		loan used in the PaymentCalc function
	*/

	var Z = 1 / (1 + (R/m));
	return ((1 - Z) * principal) / (Z * (1 - Math.pow(Z,n)));
}
