Formula for calculating the total interest payable over the life of a loan
If you know the monthly payment and the number of payments, the total of payments is $RT$, so the total interest you pay is $RT-P$. The fact that the interest is accrued monthly and payments are made in arrears only go into calculating the payment from the interest rate, which has already been done for us.