http://en.wikipedia.org/wiki/Cutting_stock_problem

There is an example in this article. In summary, assume you have a bar 5600mm long. You must cut various sizes from the bar, ranging from 22 @ 1300mm up to 20 @ 2200mm.

The article states that there are 308 possible patterns. Is there a simple formula for calculating this (I dont believe that there is)?

I think this has to be iterated. For example, if 9 is the longest length, and 1 is the shortest length, my starting point would be :-

1,1,1,1,..... until you cant fit any more 1's in (ie 1,1)
now see if you can fit any others in (eg 1,1,2 or 1,1,3) and iterate (eg 1,1,3,3)
now replace the last 1 in the first solution with the next item (ie 2) so you now have 1,2 and iterate again (eg 1,2,2 or 1,2,3 etc etc)
and repeat until you have the maximum (probably 9,9,9,9,9,9,9 etc)

Is my theory correct? If it is, any suggestions as to how to program it