Hi

I am trying to figure out how to duplicate a, financial, calculation

that uses the caret, Exponentiation.

Here's the formula...

A = 0.0755

B = 34

C = 50000

D = 22448

result = ((C-D)*A/12)/(1-(1+A/12)^(-B))+D*A/12

It calculates loan repayments based on interest rate (A), number of

payments (B), total loan amount (C) and a residual amount (D).

This calculation will work when the caret (Exponentiation) is used,

however this is not available in Javascript. So, to get this formula to

work in Javascript some other method needs to be used.

I have found examples of how to do Exponentiation, like this:

/************************************************** *********/

function powmod(base,exp,modulus)

{

var accum=1, i=0, basepow2=base;

while ((exp>>i)>0)

{

if(((exp>>i) & 1) == 1){accum = (accum*basepow2) % modulus;};

basepow2 = (basepow2*basepow2) % modulus;

i++;

};

return accum;

}

/************************************************** *********/

This function comes from here

http://www.math.umbc.edu/~campbell/N...pt.html#PowMod (some handy stuff

there) but I can't replicate the calculation I have posted using a

function like that.

Anyone know how to do this?

Thanks!