aboutsummaryrefslogtreecommitdiff
path: root/challenge-047/user-person
diff options
context:
space:
mode:
authoruser-person <60802990+user-person@users.noreply.github.com>2020-02-16 04:26:01 -0500
committerGitHub <noreply@github.com>2020-02-16 04:26:01 -0500
commitca0bcb9dc1b66cbb1fefa71b8e647614f640bfb4 (patch)
treee8bd9fd9cf99b3423d8cf23cb27a98da609c9033 /challenge-047/user-person
parentfa58921bcc3aee58395f15fbf3776f75a2589e68 (diff)
downloadperlweeklychallenge-club-ca0bcb9dc1b66cbb1fefa71b8e647614f640bfb4.tar.gz
perlweeklychallenge-club-ca0bcb9dc1b66cbb1fefa71b8e647614f640bfb4.tar.bz2
perlweeklychallenge-club-ca0bcb9dc1b66cbb1fefa71b8e647614f640bfb4.zip
Update ch-2.pl
Diffstat (limited to 'challenge-047/user-person')
-rw-r--r--challenge-047/user-person/perl/ch-2.pl9
1 files changed, 7 insertions, 2 deletions
diff --git a/challenge-047/user-person/perl/ch-2.pl b/challenge-047/user-person/perl/ch-2.pl
index 1e9d4c4f65..a501321878 100644
--- a/challenge-047/user-person/perl/ch-2.pl
+++ b/challenge-047/user-person/perl/ch-2.pl
@@ -27,17 +27,22 @@ sub firstDigit {
while ($number >= 10) {
$number /= 10;
}
- return $number;
+ return int($number);
}
for (my $i = 100; $count < $QUANTITY ; ++$i) {
$first = firstDigit $i;
$last = $i % 10;
+ my $formedBy = ($first * 10) + $last;
- if ( $i % $first == 0 && ($last == 0 || $i % $last == 0 )) {
+ if ( $i % $formedBy == 0 ) {
print "$i ";
++$count;
}
}
print "\n";
+
+__END__
+output:
+ 100 105 108 110 120 121 130 132 135 140 143 150 154 160 165 170 176 180 187 190