Skip to content
Permalink
Fetching contributors…
Cannot retrieve contributors at this time
14 lines (10 sloc) 449 Bytes
#!/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);
You can’t perform that action at this time.