You are viewing a single comment's thread. Return to all comments →
Hi, can you please explain why are you giving the 3rd "return true" statement in the isPrime method?
Hi. The idea is to see if our number n is divisible by any numbers (not including 1 and n). If it's divisible by any such numbers, it is not prime, and we return false. If it's not divisible by any of these numbers, we come out of the for loop, and return true since our number is prime.