Only test numbers up to sqrt(x).