-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathp055.py
26 lines (22 loc) · 1.16 KB
/
p055.py
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
################################################################################
# P55: Lychrel numbers #
################################################################################
# #
# How many Lychrel numbers are there below ten-thousand? #
# #
################################################################################
# Problem found at projecteuler.net #
# Author: ncfgrill #
################################################################################
total, found = 0, set()
for i in range(1, 10000):
if i in found: continue
save, n, num = [i], 0, i
while n < 50:
num += int(str(num)[::-1])
if str(num) == str(num)[::-1]: break
else: save.append(num)
n += 1
if n < 50: found.update(save)
else: total += 1
print('Lychrel numbers below 10000:', total)