summaryrefslogblamecommitdiffstats
path: root/038.pl
blob: 78c256cf40d75d407b99dff7dcbb4a18d5c31ac4 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14













                                                                    
#!/usr/bin/perl
use strict;
use warnings;

my $max = 0;
for my $n (2..9) {
    for my $val (1..99999) {
        my $pandigital = join '', map { $val * $_ } 1..$n;
        next if length($pandigital) != 9;
        next if join('', sort split //, $pandigital) ne '123456789';
        $max = $pandigital if $pandigital > $max;
    }
}
print "$max\n";