0

I am trying to solve multiple instances of the same problem using FindInstance.

myList={}
listP={3,5,7,..}
For[v = 1, v <= Length[listP], v++, Print[v]; 
 myList = Append[myList, 
   FindInstance[a*a + b*b == listP[v] && a > 0 && b >= a, {a, b}, 
    Integers, 100000]]]

There is a message FindInstance : The system contains a nonconstant expression

I do not know why listP[v] is nonconstant. Do you ?

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
montardon
  • 121
  • 1

1 Answers1

1

modifying your code to avoid For and Append (both of which are slow for lists with large number of entries):

listP = {3, 5, 7};
myList = Map[FindInstance[a*a + b*b == # && a > 0 && b >= a, {a, b}, Integers, 
100000] &, listP]
(* {{}, {{a -> 1, b -> 2}}, {}} *)
Ali Hashmi
  • 8,950
  • 4
  • 22
  • 42