use strict;
use warnings;
use v5.12;
use constant TOP => 1000000;
say "1 is prime.";
say "2 is prime.";
my $found = 2; # We already found 1 and 2.
for( my $i = 3; $i < TOP; $i += 2 ) {
my $qualifies = 1;
for( my $j = $i - 2; $j > 1; $j -= 2 ) {
if( $i % $j == 0 ){
$qualifies = 0;
last;
}
}
if( $qualifies ) {
say "$i is prime.";
$found++;
}
}
say "Found $found primes between 1 and ", TOP, ".\n";