Matt Owen

source code for "files/pe/pe_052.pl"

return to portfolio
  1.  #!/usr/bin/perl
  2.  
  3.  use strict;
  4.  use warnings;
  5.  
  6.  # do they have the same digits?
  7.  sub has_same_digits {
  8.   my ($first) = join('', sort split //, shift);
  9.   for (@_) {
  10.   my ($test) = join('', sort split //, $_);
  11.   return 0 unless $first eq $test;
  12.   }
  13.   return 1;
  14.  }
  15.  
  16.  for (my $k=1; 1; $k++) {
  17.   if (has_same_digits($k, 2*$k, 3*$k, 4*$k, 5*$k, 6*$k)) {
  18.   print $k;
  19.   last;
  20.   }
  21.  }