Only check up to the sqrt of num in isprime()