We consider compound distributions where the counting distribution has the property that the ratio between successive probabilities may be written as the ratio of two polynomials. We derive a recursive algorithm for the compound distribution, which is more efficient than the one suggested by Panjer & Willmot (1982) and Willmot & Panjer (1987). We also derive a recursive algorithm for the moments of the compound distribution. Finally, we present an application of the recursion to the problem of calculating the probability of ruin in a particular mixed Poisson process.