aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLubos Kolouch <lubos@kolouch.net>2020-01-02 14:32:22 +0100
committerLubos Kolouch <lubos@kolouch.net>2020-01-02 14:32:22 +0100
commit2e2b95b0d1cc70d2306ae29173f6ff5dd0a960be (patch)
treef4ed1f869ba4cfaff113b2fa5eca7a46b7067c5a
parente2f2f0613343e027f947facdc835557b835e5284 (diff)
downloadperlweeklychallenge-club-2e2b95b0d1cc70d2306ae29173f6ff5dd0a960be.tar.gz
perlweeklychallenge-club-2e2b95b0d1cc70d2306ae29173f6ff5dd0a960be.tar.bz2
perlweeklychallenge-club-2e2b95b0d1cc70d2306ae29173f6ff5dd0a960be.zip
Challenge 1 week 41 LK Perl
-rw-r--r--challenge-041/lubos-kolouch/perl5/ch-1.pl45
1 files changed, 45 insertions, 0 deletions
diff --git a/challenge-041/lubos-kolouch/perl5/ch-1.pl b/challenge-041/lubos-kolouch/perl5/ch-1.pl
new file mode 100644
index 0000000000..72218333c5
--- /dev/null
+++ b/challenge-041/lubos-kolouch/perl5/ch-1.pl
@@ -0,0 +1,45 @@
+#!/usr/bin/perl
+#===============================================================================
+#
+# FILE: ch-1.pl
+#
+# USAGE: ./ch-1.pl
+#
+# DESCRIPTION: https://perlweeklychallenge.org/blog/perl-weekly-challenge-041/
+#
+# Write a script to display attractive number between 1 and 50.
+#
+# OPTIONS: ---
+# REQUIREMENTS: ---
+# BUGS: ---
+# NOTES: ---
+# AUTHOR: YOUR NAME (),
+# ORGANIZATION:
+# VERSION: 1.0
+# CREATED: 01/02/2020 02:23:28 PM
+# REVISION: ---
+#===============================================================================
+
+use strict;
+use warnings;
+use Math::Factor::XS qw/count_prime_factors/;
+use Math::Prime::XS qw/is_prime/;
+
+sub is_attractive {
+ my $what = shift;
+
+ return is_prime(count_prime_factors($what));
+}
+
+# TESTS
+
+use Test::More;
+
+is(is_attractive(20),1);
+is(is_attractive(23),'');
+is(is_attractive(28),1);
+is(is_attractive(256),'');
+
+done_testing;
+
+