aboutsummaryrefslogtreecommitdiff
path: root/challenge-137/lubos-kolouch/python/ch-2.py
blob: ccc74c8ac8e1b69474fda7daed14c93824e89298 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
def is_lychrel_number(what: int):

    """ Check if the number is Lychrel """
    iter_count = 0

    while iter_count < 500:
        iter_count += 1

        what += int(str(what)[::-1])

        if what >= 10_000_000:
            break

        if what == int(str(what)[::-1]):
            return 0
    return 1


assert is_lychrel_number(56) == 0
assert is_lychrel_number(57) == 0
assert is_lychrel_number(59) == 0
assert is_lychrel_number(10911) == 1