perlweeklychallenge

May 07, 2019 08:09

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.


# perl -le 'print join"\n",map{$_%(eval join"+",split"",$_)?():$_}1..50'
1
2
3
4
5
6
7
8
9
10
12
18
20
21
24
27
30
36
40
42
45
48
50

perl

Previous post Next post
Up