aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-156/pokgopun/perl/ch-1.pl12
1 files changed, 1 insertions, 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);