The following little problem caught my attention yesterday. I found it in New Scientist’s Brain Twister 16: Order, Order!
Arrange the digits 1–9 in a line so that each pair of adjacent digits sums to a prime number.
It's not a difficult problem. Here is a permalink to some SageMathCell code that does the job of finding all possible such arrangements of the digits. There are 140 out of a total of 362,880 permutations. Every number of course has its reversal within this list as well. Thus our first number (123476589) has its reversal (985674321) as the last member of the list.
123476589, 123498567, 123856749, 123894765, 125674389, 125674983, 129438567, 129476583, 129834765, 129856743, 143298567, 143892567, 147652389, 147652983, 147658329, 147658923, 149238567, 149832567, 165238947, 165298347, 165832947, 165892347, 167432589, 167432985, 167438529, 167438925, 167492385, 167492583, 167498325, 167498523, 321476589, 321498567, 321658947, 321674985, 325894167, 325894761, 329856147, 329856741, 341298567, 347612589, 347612985, 347658921, 349852167, 385216749, 385294167, 385294761, 385612947, 385674129, 385674921, 389214765, 389256147, 389256741, 389412567, 389476125, 389476521, 521674389, 521674983, 523894167, 523894761, 529834167, 529834761, 561238947, 561298347, 567412389, 567412983, 567438921, 567498321, 583216749, 583294167, 583294761, 583476129, 583492167, 589216743, 589234167, 589234761, 589432167, 589476123, 741652389, 741652983, 741658329, 741658923, 743216589, 743298561, 743856129, 743892165, 743892561, 749216583, 749238561, 749832165, 749832561, 749856123, 761234985, 761258349, 761258943, 761294385, 761432589, 761432985, 761438529, 761438925, 761492385, 761492583, 761498325, 761498523, 765214389, 765214983, 765238941, 765298341, 765832149, 765832941, 765834129, 765834921, 765892143, 765892341, 765894123, 765894321, 921438567, 921476583, 921658347, 921674385, 923856147, 923856741, 925834167, 925834761, 941238567, 943852167, 947612385, 947612583, 947658321, 983214765, 983256147, 983256741, 983412567, 983476125, 983476521, 985216743, 985234167, 985234761, 985612347, 985674123, 985674321
This got me thinking about five digit numbers with this property. The reason for focusing on five digit numbers is that my diurnal age, since I turned 10000 days old, always consists of five digits. So what are the five digit numbers with this property given that zero is not allowed and no digits can repeat. The earlier code can be easily modified (permalink) to give us the numbers we want. It turns out that there are 222 numbers out of a total of 15120. Here they are:
12347, 12349, 12385, 12389, 12567, 12583, 12589, 12943, 12947, 12983, 12985, 14325, 14329, 14385, 14389, 14765, 14923, 14925, 14983, 14985, 16523, 16529, 16583, 16589, 16743, 16749, 21438, 21476, 21498, 21658, 21674, 23416, 23476, 23498, 23856, 23894, 25614, 25674, 25834, 25894, 29416, 29438, 29476, 29834, 29856, 32147, 32149, 32165, 32167, 32561, 32567, 32589, 32941, 32947, 32985, 34125, 34129, 34165, 34167, 34761, 34765, 34921, 34925, 34985, 38521, 38529, 38561, 38567, 38921, 38925, 38941, 38947, 41238, 41256, 41258, 41298, 41652, 41658, 43216, 43256, 43258, 43298, 43852, 43856, 43892, 47612, 47652, 47658, 49216, 49238, 49256, 49258, 49832, 49852, 49856, 52143, 52147, 52149, 52167, 52341, 52347, 52349, 52389, 52941, 52943, 52947, 52983, 56123, 56129, 56143, 56147, 56149, 56741, 56743, 56749, 58321, 58329, 58341, 58347, 58349, 58921, 58923, 58941, 58943, 58947, 61234, 61238, 61258, 61294, 61298, 61432, 61438, 61492, 61498, 65214, 65234, 65238, 65294, 65298, 65832, 65834, 65892, 65894, 67412, 67432, 67438, 67492, 67498, 74123, 74125, 74129, 74165, 74321, 74325, 74329, 74385, 74389, 74921, 74923, 74925, 74983, 74985, 76123, 76125, 76129, 76143, 76149, 76521, 76523, 76529, 76583, 76589, 83214, 83216, 83256, 83294, 83412, 83416, 83476, 83492, 85214, 85216, 85234, 85294, 85612, 85614, 85674, 89214, 89216, 89234, 89256, 89412, 89416, 89432, 89476, 92143, 92147, 92165, 92167, 92341, 92347, 92385, 92561, 92567, 92583, 94123, 94125, 94165, 94167, 94321, 94325, 94385, 94761, 94765, 98321, 98325, 98341, 98347, 98521, 98523, 98561, 98567
Again it can be noted that every number in this list has its reversal in this list because both a number and its reversal will satisfy the criterion. Thus for 12347, we will also find 74321.
Of these 222 numbers, 30 are prime:
12347, 12583, 12589, 12983, 14389, 14923, 14983, 16529, 32561, 32941, 34129, 38561, 38567, 38921, 52147, 56123, 56149, 58321, 58921, 58943, 74923, 76123, 76129, 92143, 92347, 92567, 94321, 98321, 98347, 98561
Of these 30, six are emirps:
- 14923 and 32941
- 34129 and 92143
- 12983 and 38921
So these six five digit numbers are indeed rather special. They are prime. Their reversals are prime and both have the property that the sums of their adjacent digits are prime (
permalink).
As one might expect, there are variations on this theme. What if we require instead that the absolute values of the differences between adjacent digits be prime? If we revert the case of the digits 1 to 9, there is only one number that satisfies and that is 864297531.
However, restricting ourselves to only five digit numbers (again with no zeroes and no repeating digits), we find surprisingly that there are 792 such numbers that satisfy. I won't list them all but here is a
permalink. Of this total, 92 are prime:
13649, 13697, 14683, 14753, 16427, 16927, 24169, 24631, 24683, 24697, 25741, 27581, 27583, 27941, 27961, 29641, 29683, 29741, 29753, 31469, 31649, 35279, 35729, 35869, 36479, 36497, 36857, 36947, 38149, 41357, 41863, 42961, 46183, 46381, 46831, 46853, 47581, 47963, 49253, 49613, 49681, 52963, 53147, 53149, 53681, 53861, 57241, 57413, 58147, 58169, 58369, 58613, 58631, 61357, 63149, 63527, 63857, 64279, 64927, 68147, 68531, 69247, 69257, 69427, 72461, 72469, 75869, 79241, 79613, 79631, 81463, 81647, 81649, 83579, 83641, 85247, 85297, 85361, 85369, 86357, 86413, 86927, 92413, 92461, 92581, 92753, 94253, 94613, 96857, 97241, 97463, 97583
Of these 92, the following 12 are emirps:
- 13697 and 79631
- 16427 and 72461
- 31649 and 94613
- 35729 and 92753
- 36479 and 97463
- 75869 and 96857
Many other variations are possible but that's enough for this post in which I've focused on two variations involving prime numbers.
No comments:
Post a Comment