aboutsummaryrefslogtreecommitdiff
path: root/challenge-007
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2019-05-10 04:36:35 +0100
committerGitHub <noreply@github.com>2019-05-10 04:36:35 +0100
commitc3a6b3130392a0af767e69b5bda94aa2e8fa4dab (patch)
tree1599dd4da464bd50a29c6fbeb2546eb8c378f9c5 /challenge-007
parent999d666528f91bae9044f8c5c58835107ed7faff (diff)
parent7bfc12366a5e1dc845a49b6924364dd1e86271a8 (diff)
downloadperlweeklychallenge-club-c3a6b3130392a0af767e69b5bda94aa2e8fa4dab.tar.gz
perlweeklychallenge-club-c3a6b3130392a0af767e69b5bda94aa2e8fa4dab.tar.bz2
perlweeklychallenge-club-c3a6b3130392a0af767e69b5bda94aa2e8fa4dab.zip
Merge pull request #130 from andrezgz/challenge-007
challenge-007 andrezgz solution
Diffstat (limited to 'challenge-007')
-rw-r--r--challenge-007/andrezgz/perl5/ch-1.pl13
1 files changed, 13 insertions, 0 deletions
diff --git a/challenge-007/andrezgz/perl5/ch-1.pl b/challenge-007/andrezgz/perl5/ch-1.pl
new file mode 100644
index 0000000000..6329562a9a
--- /dev/null
+++ b/challenge-007/andrezgz/perl5/ch-1.pl
@@ -0,0 +1,13 @@
+#!/usr/bin/perl
+
+# https://perlweeklychallenge.org/blog/perl-weekly-challenge-007/
+# Challenge #1
+# Print all the niven numbers from 0 to 50 inclusive, each on their own line.
+# A niven number is a non-negative number that is divisible by the sum of its digits.
+
+use strict;
+use warnings;
+
+#0 is not a niven number because it in not divisible by 0. So I start with 1.
+use List::Util qw(sum);
+map { CORE::say unless ( $_ % sum(split //) ) } (1..50);