title: Excel PMT function in Javascript result is a little off
body: <p>I run the following Excel function to calculate weekly re-payments.</p>
  
  <pre><code>CELL B4 = 15000
  =(PMT(6.5%/12,60,(-B4),(0.2*B4),1))*12/52
  </code></pre>
  
  <p>Where 6.5% = rate, 60 = number of payments, 0.2*15000 = balloon and *12/52 is for calculating weekly repayments.</p>
  
  <p>The output of the above is 57.62, however when coding it up in JS I end up with 77.11 as the result. After checking through it several times I can't seem to find where I've gone wrong.</p>
  
  <p>Calculation for PMT is done as follows.</p>
  
  <pre><code>var q = Math.pow(1 + rate_per_period, number_of_payments);
  return -(rate_per_period * (future_value + (q * present_value))) / ((-1 + q) * (1 + rate_per_period * (type)));
  </code></pre>
  
  <p>I've created <a href="https://jsfiddle.net/scnjLzw3/" rel="nofollow noreferrer">a fiddle</a> showing my PMT calculations.</p>
  
  <p>Also, I am using an almost exact copy of the accepted answer in another question <a href="https://stackoverflow.com/questions/2094967/excel-pmt-function-in-js">here on SO</a> but mine varies slightly.</p>