Improved is_prime by count up to sqrt(num) instead of num/2