【发布时间】:2019-03-28 06:12:54
【问题描述】:
我正在尝试按照随附的屏幕截图计算 EMI。但我的计算略有不同。到目前为止我所做的如下:
function interest($investment,$year,$rate=15,$n=1){
global $total_result, $total_interest, $totalamount;
$accumulated=0;
if ($year > 1){
$accumulated=interest($investment,$year-1,$rate,$n);
}
$accumulated += $investment;
$rateC = $rate / 100;
$result = $rateC / 12 * pow(1 + ($rateC) / 12, ($year * 12)) / (pow(1 + ($rateC) / 12, ($year * 12)) - 1) * $accumulated;
$result = 85.60;
for ($i=0; $i < 12; $i++) {
// echo round($accumulated,2).'<br>';
$accumulated = $accumulated * pow(1 + $rate/(100 * $n),$n);
$innntrest = ($accumulated - $investment) / 12;
$i_result = $result - $innntrest;
$accumulated = $investment - $i_result;
$investment = $accumulated;
echo '<br>***'.round($result,2).'***'.round($i_result,2).'***'.round($innntrest,2).'<br>';
$total_result = $total_result + round($result,2);
$total_interest = $total_interest + $i_result;
$totalamount = $totalamount + $innntrest;
}
return $accumulated;
}
Where $investment=1000(loan amount), $year=1 (loan term), $rate=5%(interest rate), $n=4 (compound)
所以我想要精确的输出作为附加的屏幕截图,那么任何人都可以帮助我使用此代码找出公式吗?提前致谢!
【问题讨论】: