from lib_misc import is_palindrome def euler_125(): upper = 10**8 ns = set() for i in range(1, upper): i2 = i * i if i2 >= upper: break for j in range(i + 1, upper): i2 += (j * j) if i2 >= upper: break if is_palindrome(i2): ns.add(i2) return sum(ns) if __name__ == "__main__": solution = euler_125() print("e125.py: " + str(solution)) assert(solution == 2906969179)