I've been racking my brain for the past several days trying to write a routine to calculate and show all posible combinations that can be made form a variable set of numbers

ie; 123 gives you 6 possible combos and 4 gives you 24

A basic buble or shell sor gets me partially there, but I'm missing the repitition of all combinations the can be made from each of the numbers in the set

123
132
231
213
312
321

Does someone have the answer. I'm now Brain dead!