From e3363927ff5511540969892106152f57cc24ea75 Mon Sep 17 00:00:00 2001 From: Michael Manring Date: Tue, 12 Apr 2022 16:05:05 +0700 Subject: remove unnecesary prime cache --- challenge-156/pokgopun/perl/ch-1.pl | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/challenge-156/pokgopun/perl/ch-1.pl b/challenge-156/pokgopun/perl/ch-1.pl index d4b4ce1e2d..7aec2aadb0 100644 --- a/challenge-156/pokgopun/perl/ch-1.pl +++ b/challenge-156/pokgopun/perl/ch-1.pl @@ -5,7 +5,6 @@ use Math::Prime::Util qw/is_prime/; my $n = shift; $n = 10 unless $n && $n =~ /^\d+$/; my $i; -my %is_prime; my @pn; { my $j = ++$i; @@ -15,16 +14,7 @@ my @pn; $j = int($j / 2); redo if $j; } - if (defined $is_prime{$sum}) - { - push @pn, $i if $is_prime{$sum}; - } else { - $is_prime{$sum} = 0; - if (is_prime($sum)){ - $is_prime{$sum} = 1; - push @pn, $i - } - } + push @pn, $i if is_prime($sum); redo if @pn < $n; } printf "%s\n", join(", ",@pn); -- cgit