Wednesday, September 14, 2005
Prime Palindromes
I was playing with an old prime number listing algorithm that I discovered back in Highschool. It's pretty simple and isn't going to find any undiscovered primes or anything like that. But playing with it, I decided to list off all the palindromes that are prime within a certain range (say, less than 10 digits).
In a very short time, I realized that there are no prime number palindromes with an even number of digits except for 11. I was puzzled for a while though because this seemed rather odd. I played with it for a while and soon discovered that this is because all even digit palindromes are divisible by 11. It's kind of odd, but it's true. I even tested all the 10, 12, and 14 digit palindromes - usually my algorithm would take quite a while to test this many numbers, but because they're all divisible by 11 (rather early in the list of primes), the algorithm stops there and moves on to the next candidate. It takes just a second or two to test all the 14 digit palindromes when testing a 14 digit prime my take a second itself.
I'll post the code here if anyone's interested
In a very short time, I realized that there are no prime number palindromes with an even number of digits except for 11. I was puzzled for a while though because this seemed rather odd. I played with it for a while and soon discovered that this is because all even digit palindromes are divisible by 11. It's kind of odd, but it's true. I even tested all the 10, 12, and 14 digit palindromes - usually my algorithm would take quite a while to test this many numbers, but because they're all divisible by 11 (rather early in the list of primes), the algorithm stops there and moves on to the next candidate. It takes just a second or two to test all the 14 digit palindromes when testing a 14 digit prime my take a second itself.
I'll post the code here if anyone's interested