We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
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.
Prime Checker
You are viewing a single comment's thread. Return to all comments →
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.
HackerRank solutions.