I want to use "while" instead of "solve block" because I need to check another method.
Why? And which algorithm do you have in mind?
I don't think that the algorithm used by Prime is the problem, but if there is no solution in the range you demand, Prime simply can't find it.