diff options
| author | user-person <60802990+user-person@users.noreply.github.com> | 2020-02-16 04:26:01 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-02-16 04:26:01 -0500 |
| commit | ca0bcb9dc1b66cbb1fefa71b8e647614f640bfb4 (patch) | |
| tree | e8bd9fd9cf99b3423d8cf23cb27a98da609c9033 /challenge-047/user-person | |
| parent | fa58921bcc3aee58395f15fbf3776f75a2589e68 (diff) | |
| download | perlweeklychallenge-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.pl | 9 |
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 |
