title: Calculating APR
body: <p>So, as the title says I need to calculate the APR for a loan. I have the following:</p>
  
  <pre><code>apr = (rate * ((Math.Pow((1 + rate), duration))) /
        ((Math.Pow((1 + rate), duration)) - 1)) -
        (installment / (loanamount - extracost));
  </code></pre>
  
  <p>But its not returning the correct value. I also tried another version of that equation with even worse results:</p>
  
  <pre><code>apr = ((loanamount + extracost) * rate * Math.Pow((1 + rate), duration)) / (Math.Pow((1 + rate),duration) - 1);
  </code></pre>
  
  <p>The calculations are all wrong. I tried adjusting some parenthesis and checking the order of operations. Any help would be greatly appreciated!</p>