Simply wants to calculate interests of an initial amount $N$, with a monthly payback $m$, and a year interest rate of $R$
I guess the interests are not cumulated each month, but just at the end of the year.
Yet each month the total amount is decremented of 1 payback.
So it does $(N-6m)R$ interests at the end of the first year
2nd year initial amount: $N-12m+(N-6m)R$
2nd year interests: $(N-18m+(N-6m)R)R$
(... while the amount is positive)
I don't find any easy way to recurse it, if it's possible?
Edit
seeing comments, I think rather interests are added each month
so with $r=R/12$
1st month interests: $(Nr) +$
2nd month interests: $(N-m+Nr)r +$
3rd month interests: $( (N-m+Nr)(1+r) -m )r +$
4th month interests: $( (N-m+Nr)(1+r)^2 -m(1+r) -m )r +$
5th month interests: $( (N-m+Nr)(1+r)^3 -m(1+r)^2 -m(1+r) -m )r +$
6th month interests: $( (N-m+Nr)(1+r)^4 -m(1+r)^3 -m(1+r)^2 -m(1+r) -m )r +$
...
xth month interests: $( (N-m+Nr)(1+r)^x -m((1+r)^x-1)/r )r $
$= (Nr-m)(1+r)^{i+1} +m$
$= I(x)$
so the loan interests after x months could be calculated with:
$\sum_{1..x} \ I(y) = (x-1)m+(Nr-m)(1+r)^2((1+r)^x-1)/r$
but not sure if it's correct...
the yth month intial amount is $I(y)/r = 1/r*( (1+r)^{y+1} *(Nr-m) +m)$ that helps to know when the loan is finished
@Limitless I'm going to check if it gives same result with your answer