From 7bfc12366a5e1dc845a49b6924364dd1e86271a8 Mon Sep 17 00:00:00 2001 From: andrezgz Date: Thu, 9 May 2019 18:08:32 -0300 Subject: challenge-007 andrezgz solution --- challenge-007/andrezgz/perl5/ch-1.pl | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 challenge-007/andrezgz/perl5/ch-1.pl 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); -- cgit