3 ms·
Is there a better way to check for an emirp other than checking if the number is prime, and then checking if its reverse is also prime?
by 0x8BADF00D 7y ago
Is there a better way to check for an emirp other than checking if the number is prime, and then checking if its reverse is also prime?
- emirp 7y agoI can think of a couple of things off the top of my head: - You can reject numbers that start with 2,4,5,6 or 8 since their reverse won't be prime. - If you're searching through a range of numbers for emirps avoid checking for the same pair twice. For example if you start at 1 and check for emirps, by the time you're checking 311 you've already checked 113 so you don't need to check 311.