isPrime method implemented