blob: d9dd8b3cc0c52c7afc4242fc3eec5b1d273eab41 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#!/usr/bin/env perl
# Challenge 047
#
# TASK #2
# Gapful Number
# Write a script to print first 20 Gapful Numbers greater than or equal to 100.
# Please check out the page for more information about Gapful Numbers.
use Modern::Perl;
my @out;
my $n = 100;
while (@out < 20) {
push @out, $n if is_gapfull($n);
$n++;
}
say join(", ", @out);
sub is_gapfull {
my($n) = @_;
my $div = substr($n,0,1).substr($n,-1,1);
return ($n % $div) == 0;
}
|