I'd be very surprised if that is the largest. I'm sure it is among the longest. But I'd bet money that the largest starts with a 9, and I'd bet a lot of money that it doesn't start with a 1. Update: I didn't notice it was only 7 digits until I wrote a short script that showed that there is no 9-digit answer, which surprised me -- but it's too early for clear thinking ATM :). I should have noted that I looked at the code and it doesn't appear to look for the largest answer, just the first answer that it finds (and it doesn't look at the possible answers from largest to smallest).
Update2: And here is the quick hack showing the first block that failed to find any 9-digit answer and then an added block to find the answer. Note that this code searches the potential solutions in order from largest to smallest so it can stop as soon as one answer is found. It isn't particularly fast to run (taking 14 seconds), but it was very fast to write. (:
use Algorithm::Loops qw( NextPermuteNum );
my @digs= (1..9);
my @map;
@map[1..9]= reverse 1..9;
do {
my $num= join '', @map[ @digs ];
for( 9, 8, 7, 5, 0 ) {
die "$num\n" if ! $_;
last if 0 != $num % $_;
}
} while( NextPermuteNum(@digs) );
my $prev= 0;
for my $len ( reverse 1..8 ) {
do {
my $num= substr( join( '', @map[ @digs ] ), 0, $len );
if( $num != $prev ) {
for( $num =~ /./g, 0 ) {
die "$num\n" if ! $_;
last if 0 != $num % $_;
}
}
$prev= $num;
} while( NextPermuteNum(@digs) );
}
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.