diff options
author | Guillermo Ramos | 2019-05-06 11:30:50 +0200 |
---|---|---|
committer | Guillermo Ramos | 2019-05-06 11:30:50 +0200 |
commit | 22801e2dc044851e27f22d2f83cd7316589cc99a (patch) | |
tree | c217c1b44139701994cda59db665d2edb43a2ca8 /007/ch1.pl | |
parent | 9fc1c2de282f2f47adb376ac8ad5d20825c695f9 (diff) | |
download | perlweekly-22801e2dc044851e27f22d2f83cd7316589cc99a.tar.gz |
[007#1]
Diffstat (limited to '007/ch1.pl')
-rwxr-xr-x | 007/ch1.pl | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/007/ch1.pl b/007/ch1.pl new file mode 100755 index 0000000..8102da6 --- /dev/null +++ b/007/ch1.pl @@ -0,0 +1,16 @@ +#!/usr/bin/env perl + +use strict; +use warnings; + +use List::Util qw(reduce); + +sub niven { + my $n = shift; + return 0 if $n == 0; + $n % (reduce { $a + $b } split(//, $n)) == 0; +} + +foreach (grep { niven $_ } (0..50)) { + print $_, "\n"; +} |