diff options
| author | Abigail <abigail@abigail.freedom.nl> | 2021-12-20 18:30:29 +0100 |
|---|---|---|
| committer | Abigail <abigail@abigail.freedom.nl> | 2021-12-20 18:30:29 +0100 |
| commit | 8254e0cdd38e99a76e12136123400a6160d6f160 (patch) | |
| tree | a2837ca2d8697b754d5e472d8c7cbc082a6958a9 /challenge-144/abigail/perl | |
| parent | 1aa8ecccec917bbdee515fef036e8f84c47dae22 (diff) | |
| download | perlweeklychallenge-club-8254e0cdd38e99a76e12136123400a6160d6f160.tar.gz perlweeklychallenge-club-8254e0cdd38e99a76e12136123400a6160d6f160.tar.bz2 perlweeklychallenge-club-8254e0cdd38e99a76e12136123400a6160d6f160.zip | |
Solutions for week 144, part 1
This is just a glorified Hello, World program. So, that's what you get!
Diffstat (limited to 'challenge-144/abigail/perl')
| -rw-r--r-- | challenge-144/abigail/perl/ch-1.pl | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/challenge-144/abigail/perl/ch-1.pl b/challenge-144/abigail/perl/ch-1.pl new file mode 100644 index 0000000000..e65ce40412 --- /dev/null +++ b/challenge-144/abigail/perl/ch-1.pl @@ -0,0 +1,36 @@ +#!/opt/perl/bin/perl + +use 5.032; + +use strict; +use warnings; +no warnings 'syntax'; + +use experimental 'signatures'; +use experimental 'lexical_subs'; + +# +# See ../README.md +# + +# +# Run as: perl ch-1.pl +# + +# +# And the upteenth time in succession, we'll use the divisors method. +# +# BBOOOOOOOOOOOOORRRRRRRRRRRRRRRIIIIIIIIIIIIIIINNNNNNNNNNNNGGGGGGGGGG +# +# Besides, ANY challenge of the form "print the first N terms of an +# OEIS sequence" is a trivial glorified hello world program. +# +# Semiprimes have either 3 (squares of primes) or 4 divisors (product +# of two primes), but should not be cubes of primes. They only cubes +# of primes < 100 are 8 and 27. +# + +use Math::Prime::Util qw [divisors]; +my %cubes = map {$_ => 1} 8, 27; + +say join ", " => grep {!$cubes {$_} && 3 <= divisors ($_) <= 4} 1 .. 100; |
