aboutsummaryrefslogtreecommitdiff
path: root/python/55-lychrel_numbers.py
blob: efdf31d4697b332fc855cc42f399fe293293b33f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from helper.palindrome import is_palindrome


def reverse_and_add(num):
    return num + int(str(num)[::-1])

def is_lychrel_number(num):
    for _ in range(50):
        num = reverse_and_add(num)
        if is_palindrome(num):
            return False
    return True

counter = 0
for i in range(10_000):
    if is_lychrel_number(i):
        counter += 1

print(counter)