Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Just create the list of values to be searched, and loop on that:

A=(9,21,28,36,40,84,112,133,156,160)
for a in A:
    for b in srange(1,a+1):
        if (a+b).is_square() and (a^2+b^2).is_square():
            print(a,b)

gives

28 21
40 9
112 84
156 133
160 36