Umm...I think that last one isn't quite right. It stops at 22, but there's no solution at 29, either. You can prove this on paper with a sieve or by changing the "6" in trueiter == 6 to a larger number, so that it continues long enough to find the next value that doesn't have a solution.
trueiter == 6
I could be wrong—I can only prove this to myself by showing it—but I think the smallest number of consecutive solutions required to find the last non-solution is bound to the smallest coefficient.