0

我有一个 AS3 函数来计算每周还款值,前提是我有贷款金额、利率和年限的值。

private function calculateRepayment(_loanAmount, _years, _interest):Number
{
    var nWeek = _years * 52;
    var nInterest = _interest/(52*100);
    var nRepayment = ( _loanAmount * nInterest *Math.pow((1+nInterest),nWeek) ) / ( Math.pow((1+nInterest),nWeek)-1 );
    return Number(nRepayment);
}

现在我需要编写一个函数来根据每周还款、利率和年限的值计算贷款金额。

任何关于转换为 AS3 或 javascript 的公式的帮助都会非常感谢,我认为理论上它是 loanAmount = 利率/利率时间。

例如:

private function calculateLoanAmount(_repaymentAmount, _years, _interest):Number
{
    // var nLoanAmount:Number = ????
    return Number(nLoanAmount);
}
4

1 回答 1

0

好的,我解决了,这是功能:

private function calculateLoanAmount(_repayment, _years, _interest):Number
{
    var p:Number = _repayment; // weekly payment
    var i:Number = (_interest / 52) * 0.01; // weekly interest factor
    var n:Number = _years * 52; // number of weekly payments - (5 years) 5*52 = 260
    var principal:Number = (p * (1 - 1 / (Math.pow(1 + i, n)))) / i;
    principal = Math.round(roundDec(principal, 0)); // prepare for output
    return Number(principal);
}
于 2013-07-31T04:03:27.810 回答