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.
One could also take advantage of the fact that all primes greater than 3 are of the form 6k+1 or 6k-1 (k=integer). This would take about sqrt(n)/3 modulo operations to test primality.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Day 25: Running Time and Complexity
You are viewing a single comment's thread. Return to all comments →
One could also take advantage of the fact that all primes greater than 3 are of the form 6k+1 or 6k-1 (k=integer). This would take about sqrt(n)/3 modulo operations to test primality.