Some minor changes to your code results in 9867312. Took my P4 3.2 w/4GB about 9.3 seconds to run it.
use strict; use warnings; use Algorithm::Permute qw( permute ); use Math::Combinatorics qw( combine ); my @arr = reverse 1 .. 9; my $m = 0; foreach my $n ( @arr ) { my $last = 0; foreach my $arr ( combine( $n, @arr ) ) { my @v = @$arr; permute { my $v = divisor(@v); if ( (my $w = join('',@v)) % $v == 0 ) { $m = $w unless $m > $w; #print "$w\n"; $last = 1; } } @v; } last if $last; } print "$m\n"; sub divisor { my $d = 1; for (reverse sort @_) { $d *= $_ unless $d % $_ == 0 } $d; }
In reply to Re^2: Puzzle: What is the largest integer whose digits are all different (and do not include 0) that is divisible by each of its individual digits?
by Tanktalus
in thread Puzzle: What is the largest integer whose digits are all different (and do not include 0) that is divisible by each of its individual digits?
by tphyahoo
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |