check the number is prime or not till square root of that number.
The program is perfect as far as the generation of prime numbers is concerned.
to save time
You don’t need to count the number of divisors, just to say whether there are any. So, to save time: