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. For your isPrime() function, I see you iterated up to n/2. This gives you a runtime of O(n). Try iterating to square root of nlike this for an O(n^(1/2)) runtime.
Prime Checker
You are viewing a single comment's thread. Return to all comments →
Hi. For your isPrime() function, I see you iterated up to n/2. This gives you a runtime of O(n). Try iterating to square root of n like this for an O(n^(1/2)) runtime.
Hope this helps.
HackerRank solutions.