From 2e2b95b0d1cc70d2306ae29173f6ff5dd0a960be Mon Sep 17 00:00:00 2001 From: Lubos Kolouch Date: Thu, 2 Jan 2020 14:32:22 +0100 Subject: Challenge 1 week 41 LK Perl --- challenge-041/lubos-kolouch/perl5/ch-1.pl | 45 +++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 challenge-041/lubos-kolouch/perl5/ch-1.pl 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; + + -- cgit