【问题标题】:as3/javascript loan formula to calculate principle from weekly rateas3/javascript 贷款公式从周利率计算本金
【发布时间】:2013-07-30 03:02:39
【问题描述】:

我有一个 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);
}

【问题讨论】:

  • 这是我为朋友开发的闪贷计算器。
  • 不应该是:var nRepayment = ( _loanAmount *Math.pow((1+nInterest),nWeek) ) / nWeek; 也就是说,我不确定这笔贷款是如何运作的,
  • 做作业的时候用这个链接tinyurl.com/l5fkktq
  • No pseudoDust 不正确应该是 var nRepayment:Number = _loanAmount * nInterest / (1 - (Math.pow(1/(1 + nInterest), nTerm)));

标签: javascript html actionscript-3 flash math


【解决方案1】:

好的,我解决了,函数如下:

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);
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-01
    相关资源
    最近更新 更多