Translating Excel formula to c# (annuity)
<p>I have a excel formula I am trying to "translate" into c# code.</p>

<p>It is used to calculate an "annuity rate" over time (for example 20 years).</p>

<pre><code>=(((1+E26/100)^D28*((1+E26/100)-1))/((1+E26/100)^D28-1))*100
</code></pre>

<p><em>D28 = 20</em> (years)</p>

<p><em>E26 = 5,00</em> (the rate in percent)</p>

<p><em>the <strong>^</strong> stands for exponent in Excel</em></p>

<p>As a result with these numbers I expect 8,02% per annum.</p>

<p>I tried several approaches using Math.Pow but wasn't successful.</p>

<p>Here is my first approach which gives me a result of 5 somehow.</p>

<pre><code>double usagePanels = 20.0
double rate = 5.0
annPanels = (Math.Pow((1 + rate / 100), usagePanels) *
           ((1 + rate / 100) - 1) /
           Math.Pow(1+rate/100, (usagePanels-1))) * 100;
</code></pre>

<p>Thank you.</p>
