b has to be prime because if we plug in n=0 then n^2+an+b=b. That should make a lot less cases to run on.