You are viewing a single comment's thread. Return to all comments →
When testing for many primes in bulk, Miller Rabin is actually quite slow. A Sieve of Eratosthenes may be faster.
But before changing your code, find out which part is slow: the prime testing, or finding the S values.
Seems like cookies are disabled on this browser, please enable them to open this website
I agree to HackerRank's Terms of Service and Privacy Policy.
Project Euler #134: Prime pair connection
You are viewing a single comment's thread. Return to all comments →
When testing for many primes in bulk, Miller Rabin is actually quite slow. A Sieve of Eratosthenes may be faster.
But before changing your code, find out which part is slow: the prime testing, or finding the S values.