(Python) from math import sqrt as sqrt pal = [] for x in range(10001): ....if str(x) == str(x)[::-1]: ........pal.append(x) with open("A261916b.txt","w") as g: ....for a in range(10001): ........flag = False ........for b in pal: ............if b > a: ................break ............for c in pal: ................if c > b: ....................break ................for d in pal: ....................if d > c: ........................break ....................if b + c + d == a and not flag: ........................g.write(str(a)+" "+str(b)+"\n") ........................flag = True ........if not flag: ............g.write(str(a)+" -1"+"\n") #David A. Consiglio, Jr., Sep 11 2015