3 ms·
I used a branch and prune algorithm, starting with the 1 digit primes and then adding digits to the right, pruning using a non-memoising prime test and testing
by dhbradshaw 9y ago
I used a branch and prune algorithm, starting with the 1 digit primes and then adding digits to the right, pruning using a non-memoising prime test and testing for left truncatability to see if the new numbers should be added to the sum. The tree came to an end fairly quickly, which made the algorithm fast.
I also avoided any string manipulation, favoring truncating by using integer division for right truncation and modulus for left truncation.
Is that similar to your algorithm?
- piinbinary 9y agoAh, I guessed that you might be taking some approach that generated numbers to try. Mine was the brute-force "calculate all primes under a million then test them all" approach.