FUNCTION getInterest LPARAMETERS pn_principal,pn_payamount,pn_paynumber LOCAL iHigh, iLow, i *!* iHigh and iLow represent the range the intetrest rate will be in iHigh = 100 && Impossbly high interest rate - the upper bracket iLow = 0 && Impossbly high interest rate - the upper bracket iTolerance = 0.00000000001 DO WHILE .t. iGuess = (iHigh + iLow)/2 pn_calc = getRate(pn_principal,iGuess,pn_paynumber) compare = pn_calc / pn_payamount DO CASE CASE compare > (1 + iTolerance) && we are too high iHigh = iGuess CASE compare < (1 - iTolerance) && we are too low iLow = iGuess OTHERWISE && we are with tol\erance EXIT ENDCASE ENDDO RETURN TRANSFORM(iGuess ) + ' %' FUNCTION getRate LPARAMETERS pn_principal,pn_i,pn_paynumber) LOCAL iRatio pn_i = pn_i / 1200 iRatio = (1 + pn_i)^pn_paynumber RETURN pn_principal* pn_i * (iRatio / (iRatio -1))This will retrun the APR.