The factorization method of the Hamiltonian in quantum mechanics is used to solve a particular type of Riccati equation. In this paper, He's homotopy perturbation method is applied to a general Riccati equation. The obtained solutions are in recursive sequence forms and, in many cases, these solutions lead to an exact solution. This property generally means that one can solve completely the eigenvalue problem for the Hamiltonian operator. The method is tested on various examples which are revealing the effectiveness and the simplicity of the method.