From decb68c5a9c212ae099534722c360da5644ba498 Mon Sep 17 00:00:00 2001 From: Lubos Kolouch Date: Sat, 26 Feb 2022 12:27:17 +0100 Subject: feat(challenge-153/lubos-kolouch/python/ch-2.py): Challenge 153 Task 2 Python LK --- challenge-153/lubos-kolouch/python/ch-2.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 challenge-153/lubos-kolouch/python/ch-2.py 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 -- cgit