I'm working my way through the Project Euler problems to help teach myself programming, so I'm looking to write a function that will return all possible permutations of a n digit number so that I can test for a condition on each permutation. So, for example, if the number was 87321 I would want the function to return 12378, 12387, 12738, 12783, ..., 87312, 87321 . They don't necessarily have to be in order. I'm having trouble figuring out how to do this. I'm thinking perhaps there is a way to create a list out of the individual digits and then use some kind of recursive iteration on the list, but it's a bit over my head. Can anyone help out?