if I have a set of n numbers and these numbers could be added together in combinations of up to m (allowing for duplications) how would I find all the possible combinations?

So say n {1,2} and m were 2 then I could have combinations that came to: 1,2,3,4.

1 from 1
2 from 1+1 or 2
3 from 1+2
4 from 2+2

However, I need to be able to do this for potentially any set of n and up to any m.

anybody got relevant algorithms floating around?

cheers,

Taffy

P.S.