#! /usr/bin/env python3 """ pe55.py https://mind.kittttttan.info/py/pe55 """ def is_lychrel(n): ss = str(n)[::-1] for i in range(50): n += int(ss) s = str(n) ss = s[::-1] if s == ss: return False return True def pe55(limit=10000): """ How many Lychrel numbers are there below ten-thousand? """ print(sum(1 for i in range(limit) if is_lychrel(i))) if __name__ == "__main__": pe55()