emi(principal, annual_rate_pct, months) using the standard formula P·r·(1+r)^n / ((1+r)^n − 1) where r is the monthly rate. A zero rate means simple division. Round to 2 decimals.emi(500000, 9, 60)
10379.16
5 lakh at 9% over 5 years.
Compute (1+r)**months once.
Guard the zero-rate branch first.