  The analysis of many physical phenomena can be reduced to the study of
solutions of differential equations with polynomial coefficients. In the
present work, we establish the necessary and sufficient conditions for the
existence of polynomial solutions to the linear differential equation
\begin{equation*} \sum_{k=0}^{n} \alpha_{k} \, r^{k} \, y''(r) +
\sum_{k=0}^{n-1} \beta_{k} \, r^{k} \, y'(r) - \sum_{k=0}^{n-2} \tau_{k} \,
r^{k} \, y(r) = 0 \, , \end{equation*} for arbitrary $n\geq 2$. We show by
example that for $n \ge 3$, the necessary condition is not enough to ensure the
existence of the polynomial solutions. Using Scheff\'{e}'s criteria, we show
that from this differential equation there are $n$-generic equations solvable
by a two-term recurrence formula. The closed-form solutions of these generic
equations are given in terms of the generalized hypergeometric functions. For
the arbitrary $n$ differential equations, three elementary theorems and one
algorithm were developed to construct the polynomial solutions explicitly. The
algorithm is used to establish the polynomial solutions in the case of $n=4$.
To demonstrate the simplicity and applicability of this approach, it is used to
study the solutions of Heun and Dirac equations.
