aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-175/walt-mankowski/perl/ch-2.pl9
1 files changed, 7 insertions, 2 deletions
diff --git a/challenge-175/walt-mankowski/perl/ch-2.pl b/challenge-175/walt-mankowski/perl/ch-2.pl
index e7853388e7..abe403e9f1 100644
--- a/challenge-175/walt-mankowski/perl/ch-2.pl
+++ b/challenge-175/walt-mankowski/perl/ch-2.pl
@@ -18,7 +18,9 @@ for my $n (2..$MAX) {
}
}
-for my $i (2..$MAX) {
+my @perfect;
+my $i = 2;
+while (@perfect < 20) {
my $tot = $totient[$i];
my $sum = $tot;
while ($tot != 1) {
@@ -26,5 +28,8 @@ for my $i (2..$MAX) {
$tot = $totient[$tot];
$sum += $tot;
}
- say $i if $sum == $i;
+ push @perfect, $i if $sum == $i;
+ $i++;
}
+
+say "@perfect";