Or he could simply iterate up until sqrt(x) by doing it like this:
for (i = 2; i*i < x; i++)]