aboutsummaryrefslogtreecommitdiff
path: root/challenge-007
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2019-05-13 00:01:33 +0100
committerGitHub <noreply@github.com>2019-05-13 00:01:33 +0100
commitf2908aa93a865cc241c6ccd4cf58a5dcda91bb5d (patch)
treeda0d7058885d74fbe737cd61c577385fe3ca2000 /challenge-007
parent342592434203f74fea84f3ee15b459a315e32510 (diff)
parentde39da4246473f42d56f6b895e8d6a11e97e89e1 (diff)
downloadperlweeklychallenge-club-f2908aa93a865cc241c6ccd4cf58a5dcda91bb5d.tar.gz
perlweeklychallenge-club-f2908aa93a865cc241c6ccd4cf58a5dcda91bb5d.tar.bz2
perlweeklychallenge-club-f2908aa93a865cc241c6ccd4cf58a5dcda91bb5d.zip
Merge pull request #139 from jaldhar/challenge-007
Challenge 7 problem 1 by Jaldhar H. Vyas
Diffstat (limited to 'challenge-007')
-rwxr-xr-xchallenge-007/jaldhar-h-vyas/perl5/ch-1.pl24
-rwxr-xr-xchallenge-007/jaldhar-h-vyas/perl6/ch-1.p615
2 files changed, 39 insertions, 0 deletions
diff --git a/challenge-007/jaldhar-h-vyas/perl5/ch-1.pl b/challenge-007/jaldhar-h-vyas/perl5/ch-1.pl
new file mode 100755
index 0000000000..1ed5de98d9
--- /dev/null
+++ b/challenge-007/jaldhar-h-vyas/perl5/ch-1.pl
@@ -0,0 +1,24 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+use 5.010;
+
+# Niven numbers are also known as Harshad numbers. Coincidentally Harshad is
+# my patronym.
+
+# This script is dedicated to the memory of my father Dr. Harshad V. Vyas
+# (1935-2019)
+
+say 0;
+
+for my $number (1 .. 50) {
+ my $total = 0;
+ for my $digit (split //, $number) {
+ $total += $digit;
+ }
+
+ if ($number % $total == 0) {
+ say $number;
+ }
+}
+
diff --git a/challenge-007/jaldhar-h-vyas/perl6/ch-1.p6 b/challenge-007/jaldhar-h-vyas/perl6/ch-1.p6
new file mode 100755
index 0000000000..306ba23ee8
--- /dev/null
+++ b/challenge-007/jaldhar-h-vyas/perl6/ch-1.p6
@@ -0,0 +1,15 @@
+#!/usr/bin/perl6
+
+# Niven numbers are also known as Harshad numbers. Coincidentally Harshad is
+# my patronym.
+
+# This script is dedicated to the memory of my father Dr. Harshad V. Vyas
+# (1935-2019)
+
+say 0;
+
+for 1 .. 50 -> $number {
+ if $number % $number.comb.sum == 0 {
+ say $number;
+ }
+}