by dhbradshaw · 9y ago · 0 comments
I first learned about truncatable primes from Project Euler problem 37: "Find the sum of the only eleven primes that are both truncatable from left to right and right to left."
https://projecteuler.net/problem=37
(I have some rust code that solves this problem in ~300 microseconds on my laptop. I bet it's possible to get it faster though. Anyone want to try?)
That’s why I don’t think speeding up such solutions beyond making it really fast using algorithmic changes/specializations is worthwhile.
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?
Mine was the brute-force "calculate all primes under a million then test them all" approach.