in reply to Golf the numbers!

Here's mine just to prove I can, but it's much sloppier than most of the examples given here. I'll have to analyze your code and see if I can make mine more efficient.

sub permute { return if $_[0] && $_[0] / length($_[0]) != int ($_[0] / length($_ +[0])); if (!length($_[1])) { print $_[0]." "; return; } for (0..length($_[1])-1) { permute($_[0].substr($_[1],$_,1), substr($_[1],0,$_).substr($ +_[1],$_+1)); } }
Incidently, I tried some larger numbers and found that the following are all the matches up through 19 digits:
1 : 1 12 : 12 123 : 123 321 123456 : 123654 321654 12345678 : 38165472 123456789 : 381654729 1234567890 : 3816547290
Then you hit 20 and start getting piles of matches. My algorithm isn't efficient enough yet to go beyond 21 or so.

EDIT:
si_lence gets ~27 iterations per second
Ted_Pride gets ~100 iterations per second
tilly gets ~154 iterations per second