A while ago I posted this. I have since discovered a few things.
1. Determining the number of ways to distribute X things in Y slots is the same formula as finding the binomial coefficients as in pascals triangle.
2. The code given in the comments is not tail recursive but is linearly recursive, which makes it much harder to remove the recursion.
This isn't to say that the recursion cannot be removed, but that it is harder than removing tail recursion.