So I finnaly finished the APR calculator and it works... for the most part.... sometimes ><. The problem is whenever I run it its hit or miss, the code i had to use can cause a timeout, but its the only way i can write the code, ill post the code below with some comments added in for your convience ^^,

the js code, I am using prototype btw
the code is on my site heres the link: http://cn.iddqd.net/aprcal.html

heres the formulas that the code is suppost to solve, that may help.
http://iddqd.net/help/calchelp.html

Well, I suspect that the reason you sometimes get no answer is because you possibly end up just "oscillating" out of the "range" you are allowing.

Example:

You start with an APR of 30% (0.30). Let's say that the actual APR is 29.0025

So you'll keep subtracting 0.005 from 0.30 until you get to 29.000 and you'll find that that's too small. So you'll add on 0.005 and be back at 29.005 and you'll find that that's too large. So you'll subtract 0.005 and be back at 29.000 and... Well, you get the idea.

The problem is that your code may *NEVER* do what is known as "converge".

If you look at the code I showed you, I started at 50% and then I added or subtracted 25% the first iteration. But then I cut the ADDITION VALUE IN HALF! So the next time I added or subtracted 12.5%. And then the next time 6.25%. And then 3.125%. And so on. EACH TIME, my add/subtract value got smaller and smaller. And so as long as the true APR is in the range of 0% to 99.999999%, I would CONVERGE on the correct answer.

The other obvious problem I see is that you report the APR only to the nearest integer percent value. This is inadequate. The US government stipulates that APRs must be accurate to within a quarter of a percent (might be more accurate than that, nowadays...that accuracy was required back in the days before financial calculators and desktop computers, when people just used big tables).

The biggest problem of all, though, is that you pre-calculate the monthly payment using the interest rate the user typed in. WRONG! When calculating the APR, you MUST IGNORE the interest rate from the user! You use the MONTHLY PAYMENT the user typed in! (Along with the loan amount and the number of months.) You are *SOLVING* for the interest rate, so how can you use what they typed in???