That’s not what you’re saying though >.< and that would be a sieve, because you’d need to generate those primes

When doing trial division, stop where the pattern repeats itself, there is no more information to be found. It’ll repeat after the square root, because that’s where the the two factors are equally large (the turning point)

You’d either stop at x-1 (all numbers smaller than itself but greater than 1), or you’d stop before passing sqrt(x)

While x-2 turns out to be safe, it doesn’t help and is incredibly arbitrary and is only there because someone expected the range function to have an inclusive end bound, causing -1 to be applied twice for a total of -2

You’d make the code either match the definition, or you’d make a meaningful optimization and argue about why it’s correct. having the last number be -2 is neither of those