I wonder how the NPV algo is done.<p>Prima facia, the way Id tackle it if I have a few extra registers is<p>1. Id write the exponent as n = R*m, where R is an integer. R = 2 is probably best.<p>2. Then Id do pascal's triangle (every element is a simple combination comb[x,y]) for the expansion of the exponent (if R = 2 binomial expansion) and add in ascending order.<p>3. Then raise the answer to the power of m.<p>Of course, I can iteratively do steps 1-2 if the interest rate is very small.