Matt Owen

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

return to portfolio
  1.  #!/usr/bin/perl
  2.  
  3.  use strict;
  4.  use warnings;
  5.  
  6.  my ($k, $root, $n) = (3, int sqrt(600851475143), 600851475143);
  7.  
  8.  for ($k=3; $k < $root; $k++)
  9.  {
  10.   if ($n%$k == 0)
  11.   {
  12.   $n/=$k;
  13.   $root = int sqrt $n;
  14.   }
  15.  }
  16.  
  17.  print $n;