Suppose you take on a loan for P Rupees, the tenure of the loan is n months (for example, n=240 for a 20-year loan), the monthly rate of interest is r (usually calculated by dividing the annual rate of interest quoted by the bank by 12, the number of months in a year, and dividing that by 100 as the rate is usually quoted as a percentage) and E Rupees is the EMI you have to pay every month. Let us use P_{i} to denote the amount you still owe to the bank at the end of the i-th month. At the very beginning of the tenure, i=0 and P_{0}=P, the principal amount you took on as a loan.

At the end of the first month, you owe the bank the original amount P, the interest accrued at the end of the month r×P and you pay back E. In other words:

P_{1} = P + r×P - E

or to rewrite it slightly differently:

P_{1} = P×(1 + r) - E

Similarly, at the end of the second month the amount you still owe to the bank is:

P_{2} = P_{1}×(1 + r) - E

or substituting the value of P_{1} we calculated earlier:

P_{2} = (P×(1 + r) - E)×(1 + r) - E

and once again expanding it and rewriting it slightly differently:

P_{2} = P×(1 + r)^{2} - E×((1 + r) + 1)

where "x^{y}" denotes "x raised to the power y" or "x multiplied by itself y times". To make this look slightly simpler, we substitute "(1 + r)" by "t" and now it looks like this:

P_{2} = P×t^{2} - E×(1 + t)

Continuing in this fashion and calculating P_{3}, P_{4}, etc. we quickly see that P_{i} is given by:

P_{i} = P×t^{i} - E×(1 + t + t^{2} + ... + t^{i-1})

At the end of n months (that is, at the end of the tenure of the loan), the total amount you owe to the bank should have become zero. In other words, P_{n}=0. This implies that:

P_{n} = P×t^{n} - E×(1 + t + t^{2} + ... + t^{n-1}) = 0

which means that:

P×t^{n} = E×(1 + t + t^{2} + ... + t^{n-1})

We can simplify this further by noticing that we have a of n terms here with a common ratio of t and a scale factor of 1. The sum of such a series is given by "(t^{n} - 1)/(t - 1)", which we substitute in the above equation to yield:

P×t^{n} = E×(t^{n} - 1)/(t - 1)

which can be rewritten as:

E = P×t^{n}×(t - 1)/(t^{n} - 1)

which can again be rewritten by substituting the value of t back as "(1 + r)" as:

E = P×r×(1 + r)^{n}/((1 + r)^{n} - 1)

and this is the formula for calculating your EMI.

Sourced from here