JavaScript 找出简单利息
什么是“简单利息”?
简单利息是一种快速计算贷款利息的方法。简单利息是通过将每日利率乘以本金乘以两个付款之间经过的天数来确定的。
简单利息公式:
简单利息公式如下:
简单利息 = (P x T x R)/100
其中,
P是本金金额
T是时间
R是利率
示例:
Input : P = 10000
R = 5
T = 5
Output :2500
We need to find simple interest on
Rs. 10,000 at the rate of 5% for 5
units of time.
Input : P = 3000
R = 7
T = 1
Output :210
计算简单利息的公式是:simple_interest = (P * T * R) / 100,其中P是本金,T是时间,R是利率。
实现: 以下是上述方法的实现:
Javascript
<script>
// JavaScript program to find simple interest for
// given principal amount, time and rate of
// interest.
let P = 1, R = 1, T = 1;
/* Calculate simple interest */
let SI = (P * T * R) / 100;
/* Print the resultant value of SI */
console.log("Simple Interest = " + SI);
</script>
输出:
Simple Interest = 0.01
时间复杂度: O(1)。
辅助空间: O(1)。
极客教程