title: C - I am calculating amortization and my results are off
body: <p>I am trying to calculate the monthly payment of a loan and it always comes out wrong.</p>
  
  <p>The formula is as follows where i is interest</p>
  
  <pre><code>((1 + i)^months /
  (1 + i)^months - 1)
  * principal * i
  </code></pre>
  
  <p>Assuming that annual interest rate and principal is an invisible floating point, can you tell me what's wrong with my formula?</p>
  
  <pre><code>double calculatePaymentAmount(int annualInterestRate, 
       int loanSize,                          
       int numberOfPayments;
  {
  double monthlyInterest = annualInterestRate / 1200.0;
  return 
      (
          pow(1 + monthlyInterest, numberOfPayments) /
          (pow(1 + monthlyInterest, numberOfPayments) - 1)
      )
      * (loanSize / 100)
      * monthlyInterest;
  }
  </code></pre>
  
  <p>For example: an interest rate of 1.25 and a loan size of 250 for 12 months gives 22.27 instead of 20.97.</p>
  
  <p>Thank you in advance.</p>
  
  <p>Edit 1: Changed monthly interest to annualInterestRate / 1200</p>