TITLE: Keep getting generating function wrong (making change for a dollar)
QUESTION [5 upvotes]: Possible Duplicate:
Making Change for a Dollar (and other number partitioning problems) 

I am working on the classic coin problem where I would like to calculate the number of ways to make change for a dollar with a given number of denominations.  From here, I am also going to be working on how to partition the number $100$ with at least two positive integers below $100$.
I have read over all the same posts on here and other sites and still I am unsure of what I am doing wrong.

The answer to our problem ($293$) is the coefficient of $x^{100}$ in the
  reciprocal of the following:
$$(1-x)(1-x^5)(1-x^{10})(1-x^{25})(1-x^{50})(1-x^{100}).$$

I do out this equation with $x = 100$ and get a really large return.  My skills are very limited and most of the sites I have been reading over use terminology and operators/symbols I am unfamiliar with.
I look at this and think it seems very straight forward but, I get answers that way off.  Are there any tips or steps that I could be overlooking?

REPLY [12 votes]: Here is how you can compute the coefficient you are after without using symbolic algebra software, just any programming language where you can handle an array of $101$ integers; I'll assume for convenience that the array is called $c$ and is indexed as $c[i]$ where $i$ ranges from $0$ to $100$, because then $c[i]$ records the coefficient of $x^i$ in a power series.
To multiply such a power series by a binomial of the form $(1-ax^k)$ (with $k>0$) is easy: the coefficient $c[i]$ must be subtracted $a$ times from $c[i+k]$ for every $i$ for which this is possible (so $i+k\leq100$). One must make sure that the old value of $c[i]$ is being subtracted from $c[i+k]$, which can be achieved (in sequential operation) by traversing the values of $i$ in decreasing order.
To divide such a power series by a binomial of the form $(1-ax^k)$ is the inverse operation, which turns out to be even easier. The inverse of subtracting $a*c[i]$ from $c[i+k]$ is adding $a*c[i]$ to $c[i+k]$, and this must be performed for all $i$ in reverse order to what was done for multiplication, namely in increasing order.
So here is schematically the computation you need to perform:

Initialise your array so that $c[0]=1$ and $c[i]=0$ for all $i>0$.
For $k=1,5,10,25,50,100$ (in any order; multiplication is commutatitve) do:

for $i=0,1,\ldots,100-k$ (in this order) do: 

add $c[i]$ to $c[i+k]$.


Now $c[100]$ gives your answer.

This computation gives you the coefficient of $x^{100}$ in the power series for $1/((1-x)(1-x^5)(1-x^{10})(1-x^{25})(1-x^{50})(1-x^{100}))$.
Note however that your question asks to "partition the number $100$ with at least two positive integers below $100$", and to find that, one should omit the case $k=100$ from the outer loop, as this contributes (only) the partition of $100$ into a single part equal to $100$. The result with this modification is $292$.