diff options
| -rw-r--r-- | challenge-169/pokgopun/perl/ch-1.pl | 13 | ||||
| -rw-r--r-- | challenge-169/pokgopun/perl/ch-2.pl | 16 |
2 files changed, 29 insertions, 0 deletions
diff --git a/challenge-169/pokgopun/perl/ch-1.pl b/challenge-169/pokgopun/perl/ch-1.pl new file mode 100644 index 0000000000..7ac35d6056 --- /dev/null +++ b/challenge-169/pokgopun/perl/ch-1.pl @@ -0,0 +1,13 @@ +use strict; +use warnings; +use Math::Prime::Util qw/is_semiprime factor/; +# +# By its definition, 1st Brilliant number is square of 1st prime numbers +# => 2*2 = 4 +my ($i,$count) = (4,0); +print($i) && $i++ && $count++; +{ + print ", $i" if is_semiprime($i) && eval(join(" - ", map{ length } factor $i ))==0 && $count++; + $i++ && redo if $count < 20; + print "\n"; +} diff --git a/challenge-169/pokgopun/perl/ch-2.pl b/challenge-169/pokgopun/perl/ch-2.pl new file mode 100644 index 0000000000..7dc4f8acfd --- /dev/null +++ b/challenge-169/pokgopun/perl/ch-2.pl @@ -0,0 +1,16 @@ +use strict; +use warnings; +use Math::Prime::Util qw/is_prime factor gcd/; +# +# By its definition, 1st Achilles number is made of first two primes, their powers are greater than 1 but with gcd=1 +# => 2*2*2*3*3 = 72 +my ($i,$count) = (72,0); +print($i) && $i++ && $count++; +{ + redo if is_prime $i && $i++; + my %factor; + $factor{$_}++ foreach factor $i; + print ", $i" if keys(%factor) > 1 && !scalar(grep{$_ < 2} values %factor) && gcd(values %factor)==1 && $count++; + $i++ && redo if $count < 20; + print "\n"; +} |
