I want to create a function that can output all the possible permutations of a given number n.
For example, suppose we have n=3 numbers:1, 2, 3
the # of permutations would be n! in this case 3!=6
the permutations would be: 123,132,213,231,321,312
Any ideas on how to create an algorithm to do this. Im thinking you would need recursion to implement this. But what would be the stopping case since you dont want infinite recursion.
MODS: ive seen several threads which discuss mathematical theories, so I thought this foum would be more appropriate than the prog forum. If you think otherwise, feel free to move it(as if you needed my permission )
thanks for all responses.
Imhotep MP
For example, suppose we have n=3 numbers:1, 2, 3
the # of permutations would be n! in this case 3!=6
the permutations would be: 123,132,213,231,321,312
Any ideas on how to create an algorithm to do this. Im thinking you would need recursion to implement this. But what would be the stopping case since you dont want infinite recursion.
MODS: ive seen several threads which discuss mathematical theories, so I thought this foum would be more appropriate than the prog forum. If you think otherwise, feel free to move it(as if you needed my permission )
thanks for all responses.
Imhotep MP