aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-153/lubos-kolouch/perl/ch-2.pl33
1 files changed, 33 insertions, 0 deletions
diff --git a/challenge-153/lubos-kolouch/perl/ch-2.pl b/challenge-153/lubos-kolouch/perl/ch-2.pl
new file mode 100644
index 0000000000..6911fdbe74
--- /dev/null
+++ b/challenge-153/lubos-kolouch/perl/ch-2.pl
@@ -0,0 +1,33 @@
+use strict;
+use warnings;
+
+
+sub calculate_factorial {
+ my $what = shift;
+
+ my $fact = 1;
+
+ $fact *= $_ for (1..$what);
+
+ return $fact;
+}
+
+sub get_factorions_sum {
+ my $what = shift;
+
+ my $sum = 0;
+
+ $sum += calculate_factorial($_) for (split //, $what);
+ return $sum;
+}
+
+
+sub is_equal {
+ my $what = shift;
+ return $what == get_factorions_sum($what);
+}
+
+use Test::More;
+is(is_equal(145), 1);
+is(is_equal(123), '');
+done_testing;