# Revision history [back]

### search for values in discrete range

I am trying to search for solutions to a pair of equations but only using a few values. I know which values give the possible answers and I want to skip the computation time associated with checking every single value up within an interval. I am using the simple code:

for a in srange(0,200):

 for b in srange(1,a+1):
if (a+b).is_square() and (a^2+b^2).is_square():
print(a,b)


which gives me the solutions I want but it computes every integer solution from 0 to 200. If I know the answers, can I search for the range like

for a in range(9,21,28,36,40,84,112,133,156,160)

and then the same as above, and it will print:

28, 21

40, 9

112, 84

156,133

160,36

Any idea how to make that work? This is not homework or anything, just doing a bit of research and I'm a new. Thanks!!

 2 None FrédéricC 3640 ●3 ●36 ●73

### search for values in discrete range

I am trying to search for solutions to a pair of equations but only using a few values. I know which values give the possible answers and I want to skip the computation time associated with checking every single value up within an interval. I am using the simple code:

for a in srange(0,200):

for a in srange(0,200):
for b in srange(1,a+1):
if (a+b).is_square() and (a^2+b^2).is_square():
print(a,b)


which gives me the solutions I want but it computes every integer solution from 0 to 200. If I know the answers, can I search for the range like

for a in range(9,21,28,36,40,84,112,133,156,160)

and then the same as above, and it will print:

28, 21

40, 9

112, 84

156,133

160,36

Any idea how to make that work? This is not homework or anything, just doing a bit of research and I'm a new. Thanks!!