Totient and isPrime function