aboutsummaryrefslogtreecommitdiff
path: root/challenge-007
diff options
context:
space:
mode:
authorandrezgz <andrezgz@gmail.com>2019-05-09 18:08:32 -0300
committerandrezgz <andrezgz@gmail.com>2019-05-09 18:08:32 -0300
commit7bfc12366a5e1dc845a49b6924364dd1e86271a8 (patch)
treea1ea78f11a9f4811183ef438da9a772b8f674540 /challenge-007
parentb6dfe831cbda4c869683fe3c5ca9ae33576c8c6f (diff)
downloadperlweeklychallenge-club-7bfc12366a5e1dc845a49b6924364dd1e86271a8.tar.gz
perlweeklychallenge-club-7bfc12366a5e1dc845a49b6924364dd1e86271a8.tar.bz2
perlweeklychallenge-club-7bfc12366a5e1dc845a49b6924364dd1e86271a8.zip
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);