Compartment models are implemented to understand the dynamic of a system. To analyze the models, a numerical tool is required. This manuscript presents an alternative numerical tool for the SIR and SEIR models. The same idea could be applied to other compartment models. The result starts with transforming the SIR model to an equivalent differential equation. The Dirichlet series satisfying the differential equation leads to an alternative numerical method to obtain the model’s solutions. The derived Dirichlet solution not only matches the numerical solution obtained by the fourth-order Runge-Kutta method (RK-4), but it also carries the long-run behavior of the system. The SIR solutions obtained by the RK-4 method, an approximated analytical solution, and the Dirichlet series approximants are graphically compared. The Dirichlet series approximants order 15 and the RK-4 method are almost perfectly matched with the mean square error less than 2 × 10−5. A specific Dirichlet series is considered in the case of the SEIR model. The process to obtain a numerical solution is done in the similar way. The graphical comparisons of the solutions achieved by the Dirichlet series approximants order 20 and the RK-4 method show that both methods produce almost the same solution. The mean square errors of the Dirichlet series approximants order 20 in this case are less than 1.2 × 10−4.