aboutsummaryrefslogtreecommitdiff
path: root/challenge-153/lubos-kolouch/python/ch-2.py
blob: 4f4090917e6b059a50d3d76ce8441f79553437fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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