diff options
| author | Lubos Kolouch <lubos@kolouch.net> | 2022-02-26 12:27:17 +0100 |
|---|---|---|
| committer | Lubos Kolouch <lubos@kolouch.net> | 2022-02-26 12:27:17 +0100 |
| commit | decb68c5a9c212ae099534722c360da5644ba498 (patch) | |
| tree | db6c3a45e22e93f9522ecc08cde564f00c437665 /challenge-153 | |
| parent | 32bc285d8a5f175aae30142ce0e7f1211af5a63e (diff) | |
| download | perlweeklychallenge-club-decb68c5a9c212ae099534722c360da5644ba498.tar.gz perlweeklychallenge-club-decb68c5a9c212ae099534722c360da5644ba498.tar.bz2 perlweeklychallenge-club-decb68c5a9c212ae099534722c360da5644ba498.zip | |
feat(challenge-153/lubos-kolouch/python/ch-2.py): Challenge 153 Task 2 Python LK
Diffstat (limited to 'challenge-153')
| -rw-r--r-- | challenge-153/lubos-kolouch/python/ch-2.py | 29 |
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 |
