You are kindly invited to find larger palindromes as substrings in 'prime'- or 'other' sequence concatenations !
[ November 25, 2003 ] Contribution by Dw (email)
I wrote a program to find such palindromic sequences with "record length", meaning, to find a sequence at least longer than the previous sequence found, and start with length 1.
The results for the first 98654 primes were:
(flank [8, 11] ) #|11|# Length 2 (center [8, 12] ) #|11|1#3| Length 3 (center [19, 26] ) |1#9|23|29|# Length 5 (center [234, 243] ) |31#7|331|337|# Length 7 * (center [647, 658] ) |100#9|1013|1019|# Length 9 * (flank [6019, 6030] ) |1010#3|10111|1013#3| Length 10 (center [18007, 18020] ) |2991#7|29921|29927|# Length 11 (center [79043, 79058] ) |13828#9|138311|138319|# Length 13 (flank [158566, 158581] ) |2#77279|277297|277#301| Length 14
Flank palindromes are ones which have two center digits, e.g 7447. Center palindromes are ones which have only one center digit, e.g 74347.
The vertical line | pipe symbol separates the respective digits, while the # marks show the start and end of the palindromic sequence.
For example, for the length 5 palindrome, the bars show that the primes involved are 19, 23, and 29. The palindrome itself is 92329.
The numbers in brackets show the position of the palindromic sequence in a string of the numbers concatenated and separated with the vertical line symbols mentioned above.
* Note that it found an earlier length 7 and length 9 sequence than the ones on your example table.
[ December 2, 2003 ] Suite by Dw (email)
I replaced the prime number detection with a sieve and did some other tweaks, though I'm running it close to the memory limit given by the sieve, so I probably won't find any larger palindromic concatenations of prime numbers for a while.
The relevant program output is:
New record found of size 19. (center [706236, 706257] )#|1292113|1292131|12921#41| New record found of size 21. (center [865835, 865858] )|157508#3|1575113|1575131|157513#7| New record found of size 22. (flank [9612474, 9612498] )#|18008113|18008131|180081#53| New record found of size 24. (flank [10621868, 10621894] )|1988911#7|19889137|19889173|1988917#9| New record found of size 26. (flank [30358705, 30358734] )|581184#97|58118537|58118573|58118579|# New record found of size 27 ( Note by PDG 916282611716282617116282619 is a palindromic prime ! ). (center [84723469, 84723498] )|16282610#9|162826117|162826171|16282619#9| New record found of size 34. (flank [122423120, 122423157] )#|234843239|234843277|234843293|2348432#99|
String length: 187895520 Last prime: 362559997
First I use a Sieve of Eratosthenes to get all primes up to the maximum prime number mentioned as "last prime". I then dump all the prime numbers found by that method into a linked list and erase the sieve array so I'll have enough memory for the next step. This consists of concatenating the printed equivalents of the numbers between |s -- e.g 2, 3, 5 becomes |2|3|5. Once that is done I run a function to find palindromes on every position in that string and print "New record found" if the longest palindrome it found originating from that position was larger than the last record.
I have 512M RAM and 256M virtual memory, and the boundary for how large a sieve I can have (unless I do tricks like using only odd numbers) is about where I am now.
The modularity of the code would make it simple to create analogous versions for other sieve based numbers, eg luckies.
Giovanni Resta and J. K. Andersen engaged to the puzzle using their own methods and insights and came up with some stunning new records ! The full story can be read in Carlos excellent puzzle page. Allow me to duplicate from both puzzlers their two largest palindromic subsequences. GR got these two solutions which beat the cited with 34 digits by Dw and span 5 primes. 51 = (1666661119 11666661137 11666661173 11666661191 11666661)203 53 = (46735376419 46735376437 46735376473 46735376491 467353764)97 JKA has two palprime record solutions spanning 5 and even 6 consecutive primes. 61 = 108767(976780119 108767976780137 108767976780173 108767976780191 1087679)76780289 105 = 19605310868013506908(9 196053108680135069119 196053108680135069137 196053108680135069173 196053108680135069191 19605310868013506919)7
[ TOP OF PAGE]