def is_lychrel(n,depth): if depth>60: return False s = str(n) if depth != 0 and useful_functions.isPalindrom(s): return True #reverse s s_r = s[::-1] n_r = int(s_r) return is_lychrel(n+n_r,depth+1)
def is_lychrel(n, depth): if depth > 60: return False s = str(n) if depth != 0 and useful_functions.isPalindrom(s): return True #reverse s s_r = s[::-1] n_r = int(s_r) return is_lychrel(n + n_r, depth + 1)
''' Created on Jan 14, 2011 @author: Jeff Patti ''' import useful_functions sum = 0 for i in range(1000000): decimal = str(i) binary = str(bin(i))[2:] if useful_functions.isPalindrom(decimal) and useful_functions.isPalindrom(binary): print decimal, binary sum += i print sum
''' Created on Jan 14, 2011 @author: Jeff Patti ''' import useful_functions sum = 0 for i in range(1000000): decimal = str(i) binary = str(bin(i))[2:] if useful_functions.isPalindrom(decimal) and useful_functions.isPalindrom( binary): print decimal, binary sum += i print sum