Thursday, 17 November 2022

Number + Reversal

I was exploring the sum of numbers and their reversals and discovered something puzzling. Specifically I was looking at how many numbers and their reversals, when added together, produce a prime number. In the range up to 10, there is only one number and that is 1 because 1+1=2. In the range up to 100, there is 1 and 10 because 10 + 1 = 11. In the range up 1000, there are 139 numbers (and thus 13.91%). They are:

1, 10, 100, 116, 118, 140, 142, 146, 158, 166, 170, 172, 178, 182, 188, 190, 196, 215, 217, 229, 239, 241, 245, 257, 265, 269, 271, 277, 281, 287, 295, 299, 314, 316, 328, 338, 340, 344, 356, 364, 368, 370, 376, 380, 386, 394, 398, 413, 415, 427, 437, 439, 443, 455, 463, 467, 469, 475, 479, 485, 493, 497, 499, 512, 514, 526, 536, 538, 542, 554, 562, 566, 568, 574, 578, 584, 592, 596, 598, 611, 613, 625, 635, 637, 641, 653, 661, 665, 667, 673, 677, 683, 691, 695, 697, 710, 712, 724, 734, 736, 740, 752, 760, 764, 766, 772, 776, 782, 790, 794, 796, 811, 823, 833, 835, 839, 851, 863, 865, 871, 875, 881, 889, 893, 895, 910, 922, 932, 934, 938, 950, 962, 964, 970, 974, 980, 988, 992, 994

However, in the range up to 10,000, there are also 139 numbers which means that no new numbers have been added (after 994, the next number is 10012). I checked and rechecked my algorithm but could find no error. It must mean that no four digit number when added to its reverse can produce a prime number. This is in fact true and can be demonstrated by considering a four digit number \(abcd\) and its reverse \(dcba\):$$1000a+100b+10c+d +1000d+100c+10b+a=1001a+110b+110c+1001d$$Each coefficient is divisible by 11 because 1001 = 7 x 11 x 13 and 110 = 2 x 5 x 11. This came as quite a surprise to me. When we check in the range up to 100,000, we find that there are 8428 numbers but again when we extend the range to one million, there are still only 8428. This means that all six digits numbers added to their reversals cannot produce primes. The reason is the same as for the four digit numbers. We find that in the range from 10,000 to 100,000, the numbers that produce primes account for about 9.21% of the total. 

Thus we could summarise: for numbers with \(n\) digits where \(n\)=1, 2, 3, ... the numbers that, when added to their reversals produce primes, total 1, 2, 139, 139, 8428, 8428, ... . I suspect this inability of numbers with an even number of digits (from 4 up) to form primes continues although SageMathCell times out when attempting a range up to ten million. Let's use the three digit numbers to understand what's going on with the numbers that have an odd number of digits. For a number \(abc\) and its reverse \(cba\) we have:$$100a+10b+c+100c+10b+a=101a+20b+101c$$The situation now is quite different because 101 and 20 have no factors in common and the former is in fact a prime number. Thus it is possible for some three digits numbers and their reverses to form prime numbers.

Let's go further and consider the five digit numbers using \(abcde\) and \(edcba\). We have:$$10000a+1000b+100c+10d+e+10000e+1000d+100c+10b+a\\=10001a+1010b+200c+1010d+10001e$$Again the coefficients have no factors in common and so it is possible for prime numbers to arise. The first such number is 10012 which, when added to its reverse 21001, gives the prime number 31013. The final five digit number is 99998 which, when added to its reverse 89999, gives the prime number 189997.

No comments:

Post a Comment