isPrime function returns true if num is prime.