How to implement the formula in code?

Hello.
Implemented a calculator using the formula: 5ccc60b6cad16533350606.png
Tried to make a function that does not operate correctly. May not correctly implemented the formula?
Condemn not for writing code, js I don't know
let credit_amount = 100000;
let proc = 0.02;
let credit_month = 1;

function formula(c3, mps, sk) {
/**
 * c3 - the total number of funds borrowed
 * mps - the amount of the monthly interest rate
 * sk - term loan, months
*/

 const znammenatel = 1 - Math.pow((1 + mps),(0 - sk));

/**
 * mp - monthly payment on loan
*/

 const mp = c3 * mps / znammenatel;
/**
 * the same formula in one line: 
 * const mp = c3 * (mps / (1 - Math.pow(1+mps, 0-sk)));
*/
 return mp;

}

result = formula(credit_amount, proc, credit_month);

console.log({result});


For example, take: 100 *(0,02/(1-(1+0,02)^-1)) = 102004
my answer is: = 101999.99999999978

the second example: 150000*(0,02/(1-(1+0,02)^-4)) = 39395
my answer is: = 39393.99999999978
March 20th 20 at 11:39
0 answer

Find more questions by tags JavaScript