sub mklist { my $num = shift; return "1" if $num == 1; return ($num,(map {$_,$_.$num} mklist($num-1))); } print join "\n", mklist(5); print "\n"; __END__ 5 4 45 3 35 34 345 2 25 24 245 23 235 234 2345 1 15 14 145 13 135 134 1345 12 125 124 1245 123 1235 1234 12345
In reply to Re: All possible number combinations in perl
by brx
in thread All possible number combinations in perl
by austinj
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |