Wednesday, April 27, 2011

Find a 2-digit number such that

Find a 2-digit number such that its square and its fifth power contain together all the digits from 1 to 9, each once and only once.

2 comments:

  1. NUM: for my $i ( 10 .. 99 ) {

    my $sq = $i * $i;
    my $pent = $i * $i * $i * $i * $i;
    my $r = $sq . $pent;

    my %look;
    while ( $r =~ /(.)/g ) { ++$look{$1}; next NUM unless ( $look{$1} == 1 ); }
    print "$i: $r\n";
    }

    ReplyDelete