aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2019-05-06 08:49:19 +0100
committerGitHub <noreply@github.com>2019-05-06 08:49:19 +0100
commit214cf005a5e8771148c40a511115193b2c0dca17 (patch)
tree35392769c925c7bfde8119a0ab5e0ae6d2cee635
parentfd0c2d3740978f4bff1c6f88f003b50a1486b167 (diff)
parentf51bc114c8c8e04f6e0221ab47319675afdf57a9 (diff)
downloadperlweeklychallenge-club-214cf005a5e8771148c40a511115193b2c0dca17.tar.gz
perlweeklychallenge-club-214cf005a5e8771148c40a511115193b2c0dca17.tar.bz2
perlweeklychallenge-club-214cf005a5e8771148c40a511115193b2c0dca17.zip
Merge pull request #126 from threadless-screw/master
ch-1.p6
-rw-r--r--challenge-007/ozzy/perl6/ch-1.p620
1 files changed, 20 insertions, 0 deletions
diff --git a/challenge-007/ozzy/perl6/ch-1.p6 b/challenge-007/ozzy/perl6/ch-1.p6
new file mode 100644
index 0000000000..ef3380f92b
--- /dev/null
+++ b/challenge-007/ozzy/perl6/ch-1.p6
@@ -0,0 +1,20 @@
+#/usr/bin/env perl6
+
+# 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.
+
+sub SumDigits ( Int $x is copy ) {
+ my $sum=0;
+ while $x != 0 {
+ $sum += $x mod 10;
+ $x= $x div 10;
+ }
+ return $sum;
+}
+
+
+sub MAIN {
+ for 0..50 -> $x {
+ say $x if $x %% SumDigits($x);
+ }
+}