I have to write a program that figures the remaining balance for a loan. the formula they give is:

balance = payment ( 1 - (1 + i)^k-n / i)

k = payment number
payment = amount of monthly payment
i = interest rate per month (annual rate/12)
n = total number of payments to be made

The code I have is:

interest2 = interest / 12;
balance = payment * (1 - (pow((1 + interest2), (number - totalnum))) / interest2);

but it doesn't work out right. i get a negative number. Any help?

------------------
Long live SFOT!

And now...your moment of Zen!

Sure you can trust the government! Just ask an Indian!