challenges

my solutions to various "programming challenge" problems
git clone https://wehaveforgeathome.hates.computer/challenges.git
Log | Files | Refs | LICENSE

003.pl (253B)


      1 #!/usr/bin/perl
      2 
      3 use strict;
      4 use warnings;
      5 
      6 my $c = 600851475143;
      7 my $i = 3;
      8 my $l = int(sqrt($c));
      9 my $last = 3;
     10 
     11 while ($i < $l) {
     12   if ($c % $i == 0) {
     13     $last = $c / $i;
     14     $c = $c / $i;
     15     $l = int(sqrt($c));
     16   }
     17   $i += 2;
     18 }
     19 
     20 print "$last\n";