aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-171/cheok-yin-fung/perl/ch-1.pl18
1 files changed, 18 insertions, 0 deletions
diff --git a/challenge-171/cheok-yin-fung/perl/ch-1.pl b/challenge-171/cheok-yin-fung/perl/ch-1.pl
new file mode 100644
index 0000000000..d3b6fb14c5
--- /dev/null
+++ b/challenge-171/cheok-yin-fung/perl/ch-1.pl
@@ -0,0 +1,18 @@
+#!/usr/bin/perl
+# The Weekly Challenge 171
+# Task 1 Abundant (Odd) Number
+use v5.30.0;
+use warnings;
+use Math::Prime::Util qw/divisor_sum/;
+
+my $N = $ARGV[0] || 20;
+my @abunt;
+my $n = 9;
+
+while (scalar @abunt < $N) {
+ $n += 2;
+ if (divisor_sum($n) > 2*$n) {
+ say $n;
+ push @abunt, $n;
+ }
+}