We present an algorithm for the symbolic computation of the pair-distribution function g(r) for arbitrary r-values of a one-component hard-sphere (HS) system within the Percus-Yevick approximation and of a hard-sphere Yukawa system within the mean-spherical approximation (MSA). The algorithm itself is formulated in a general way with examples given in the symbolic programming language of Mathematica. It is shown that (i) for very close packed HS systems (i.e. for packing fractions n>=0.4), and (ii) for only weakly screened hard-sphere Yukawa systems in the MSA the contributions of shells with r>=7sigma to integrals involving factors of [g(r)-1] can be effectively accounted with by using the numerical results of the algorithm.