def test0036(self): from id_0036 import is_palindrome, to_base_k self.assertEqual(is_palindrome("585"), True) self.assertEqual(is_palindrome("586"), False) self.assertEqual(is_palindrome("50"), False) self.assertEqual(to_base_k(3, 2), "11") self.assertEqual(to_base_k(3, 3), "10") self.assertEqual(to_base_k(5, 2), "101") for x in range(1, 10 ** 3): self.assertEqual(str(x), to_base_k(x, 10)) self.assertEqual(is_palindrome(to_base_k(585, 2)), True)
def is_Lychrel_below_1000(num): n = 0 while True: ss = list(str(num)) ss.reverse() rev = int(''.join(ss)) num = num + rev if is_palindrome(str(num)): return False if n == 50: return True n += 1