aboutsummaryrefslogtreecommitdiff
path: root/challenge-153/lubos-kolouch/python/ch-2.py
diff options
context:
space:
mode:
authordrbaggy <js5@sanger.ac.uk>2022-02-28 06:42:52 +0000
committerdrbaggy <js5@sanger.ac.uk>2022-02-28 06:42:52 +0000
commit79466de7ef71946f9ef6acd21d9b80fede2d7ef3 (patch)
treefc7250288695fe29a2fe4294bb6371ccd28c46b4 /challenge-153/lubos-kolouch/python/ch-2.py
parentad4031ad944a6ee247c953c7d3e8c98e27fe5f23 (diff)
parent708f0b09a688c48e140d552c4116678099bb0581 (diff)
downloadperlweeklychallenge-club-79466de7ef71946f9ef6acd21d9b80fede2d7ef3.tar.gz
perlweeklychallenge-club-79466de7ef71946f9ef6acd21d9b80fede2d7ef3.tar.bz2
perlweeklychallenge-club-79466de7ef71946f9ef6acd21d9b80fede2d7ef3.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'challenge-153/lubos-kolouch/python/ch-2.py')
-rw-r--r--challenge-153/lubos-kolouch/python/ch-2.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/challenge-153/lubos-kolouch/python/ch-2.py b/challenge-153/lubos-kolouch/python/ch-2.py
new file mode 100644
index 0000000000..4f4090917e
--- /dev/null
+++ b/challenge-153/lubos-kolouch/python/ch-2.py
@@ -0,0 +1,29 @@
+""" Challenge 153 Task 2"""
+
+
+def calculate_factorial(what: int):
+ """Calculate the factorial"""
+
+ fact = 1
+
+ for i in range(1, what + 1):
+ fact *= i
+
+ return fact
+
+
+def get_factorions_sum(what: int):
+ """Get the factorions sum"""
+
+ my_sum = sum(calculate_factorial(int(i)) for i in str(what))
+
+ return my_sum
+
+
+def is_equal(what: int):
+ """Test the equality"""
+ return what == get_factorions_sum(what)
+
+
+assert is_equal(145) == 1
+assert is_equal(123) == 0