Friday 30 June 2023

The 4 x 3 Sliding Block Puzzle

Today I came across the 4 x 3 sliding block puzzle that is a variant of the more famous Sam Loyd sliding block 15-puzzle that features a 4 x 4 configuration with 15 numbers and one blank space. The 4 x 3 puzzle has 11 numbers and one blank space. See Figure 1.


Figure 1

I came across this puzzle in the context of my diurnal age (27116 days) and OEIS  A090166:


 A090166

Number of configurations of the 4 X 3 variant of Sam Loyd's sliding block 15-puzzle that require a minimum of n moves to be reached, starting with the empty square in one of the corners.


It turns out that there are exactly 27116 configurations of this puzzle (with empty square in one of the corners) that require a minimum of 49 moves. Up to the maximum of 53 moves, the initial members of the sequence are:

1, 2, 4, 9, 20, 37, 63, 122, 232, 431, 781, 1392, 2494, 4442, 7854, 13899, 24215, 41802, 71167, 119888, 198363, 323206, 515778, 811000, 1248011, 1885279, 2782396, 4009722, 5621354, 7647872, 10065800, 12760413, 15570786, 18171606, 20299876, 21587248, 21841159, 20906905, 18899357, 16058335, 12772603, 9515217, 6583181, 4242753, 2503873, 1350268, 643245, 270303, 92311, 27116, 5390, 1115, 86, 18 

Figure 2 shows a graph of the above numbers:


Figure 2

For this particular so-called 11 puzzle, there are 18 configurations that require the maximum of 53 moves. These are shown in Figure 3.


Figure 3: source

Figure 4 shows a comparison of the 4 x 3 puzzle with other puzzle sizes.


Figure 4: source

Figure 5 shows a 3 x 3 puzzle for which there a two configurations that require the maximum of 31 moves.

Figure 5

Sunday 18 June 2023

Gray Code

I'd never heard of this before. I came across it when looking at the properties associated with my diurnal age of 27104. One of its properties is that it's a member of OEIS A265385:


 A265385

Sequence defined by a(1) = a(2) = 1 and a(\(n\)) = gray(a(\(n\)-1) + a(\(n\)-2)), with gray(\(m\)) = A003188(\(m\)).


Here's what Wikipedia has to say on the topic:
The reflected binary code (RBC), also known as reflected binary (RB) or Gray code after Frank Gray, is an ordering of the binary numeral system such that two successive values differ in only one bit (binary digit).

For example, the representation of the decimal value "1" in binary would normally be "001" and "2" would be "010". In Gray code, these values are represented as "001" and "011". That way, incrementing a value from 1 to 2 requires only one bit to change, instead of two.

Gray codes are widely used to prevent spurious output from electromechanical switches and to facilitate error correction in digital communications such as digital terrestrial television and some cable TV systems.

Table 1 shows the relationships between binary, gray code and decimal.


Table 1: source


To understand how this OEIS arises, I needed a way to convert binary to gray code and this site provided some Python code to achieve this. I modified it slightly to accept decimal input (permalink). Armed with this, I began to investigate the sequence. 

The initial values are 1 and 1 and these sum to 2. The binary code for 2, as can be seen from Table 1, is 0010 which the Gray code converts to 0011 and this has a decimal equivalent of 3. Proceeding like this we have:
  • 1 first seed value
  • 1 second seed value
  • 1 + 1 = 2 --> 3
  • 1 + 3 = 4 --> 6
  • 3 + 6 = 9 --> 13
  • 6 + 13 =19 --> 26
  • 13 + 26 = 39 --> 52
  • 26 + 52 = 78 --> 105
  • 52 + 105 = 157 --> 211
  • 105 + 211 = 316 --> 418
  • 211 + 418 = 629 --> 847
  • 418 + 847 = 1265 --> 1673
  • 847 + 1673 = 2520 --> 3380
  • 1673 + 3380 = 5053 --> 6755
  • 3380 + 6755 = 10135 --> 13404
  • 6755 + 13404 = 20159 --> 27104

The OEIS comments note that:
This recurrence is reminiscent of Fibonacci's, except that the result of each step is passed through the binary-reflected Gray code mapping, which introduces a degree of pseudo-randomness. 

However, the ratio of successive terms doesn't approach the Golden Ratio but instead fluctuates around 2 with a variation of about 1% above and below. Here are the successive ratios of \( \frac{(n+1)^{th} \text{ term}}{n^{th} \text{ term}}\):

3.0000000, 2.0000000, 2.1666667, 2.0000000, 2.0000000, 2.0192308, 2.0095238, 1.9810427, 2.0263158, 1.9752066, 2.0203228, 1.9985207, 1.9843079, 2.0220830, 1.9752804, 2.0203033, 1.9986779, 1.9841292, 2.0220523, 1.9752920, 2.0202956, 1.9986750, 1.9841298, 2.0220479, 1.9752930, 2.0202950, 1.9986749, 1.9841299, 2.0220478, 1.9752930, 2.0202950, 1.9986725

There's lots of YouTube videos explaining about Gray code and I'm happy to have finally stumbled upon this clever manipulation of binary code. The OEIS A003188 referred to above lists the decimal equivalents of the Gray code for integers \(n\). The result is a permutation of the order of the cardinal numbers as shown for \(n\) up to 70:

  • 0 --> 0
  • 1 --> 1
  • 2 --> 3
  • 3 --> 2
  • 4 --> 6
  • 5 --> 7
  • 6 --> 5
  • 7 --> 4
  • 8 --> 12
  • 9 --> 13
  • 10 --> 15
  • 11 --> 14
  • 12 --> 10
  • 13 --> 11
  • 14 --> 9
  • 15 --> 8
  • 16 --> 24
  • 17 --> 25
  • 18 --> 27
  • 19 --> 26
  • 20 --> 30
  • 21 --> 31
  • 22 --> 29
  • 23 --> 28
  • 24 --> 20
  • 25 --> 21
  • 26 --> 23
  • 27 --> 22
  • 28 --> 18
  • 29 --> 19
  • 30 --> 17
  • 31 --> 16
  • 32 --> 48
  • 33 --> 49
  • 34 --> 51
  • 35 --> 50
  • 36 --> 54
  • 37 --> 55
  • 38 --> 53
  • 39 --> 52
  • 40 --> 60
  • 41 --> 61
  • 42 --> 63
  • 43 --> 62
  • 44 --> 58
  • 45 --> 59
  • 46 --> 57
  • 47 --> 56
  • 48 --> 40
  • 49 --> 41
  • 50 --> 43
  • 51 --> 42
  • 52 --> 46
  • 53 --> 47
  • 54 --> 45
  • 55 --> 44
  • 56 --> 36
  • 57 --> 37
  • 58 --> 39
  • 59 --> 38
  • 60 --> 34
  • 61 --> 35
  • 62 --> 33
  • 63 --> 32
  • 64 --> 96
  • 65 --> 97
  • 66 --> 99
  • 67 --> 98
  • 68 --> 102
  • 69 --> 103
  • 70 --> 101

Saturday 17 June 2023

Primes Formed By Concatenation

 Suppose we laid down the following criteria that prime numbers had to adhere to:

  • formed from the \(n^{th}\) number and the  \(n^{th}\) prime
  • no repeating digits
  • sum of digits is a prime number
The criterion that there must be no repeating digits means that we must have a finite number of such primes because, as the primes get larger, digits must repeat. Concatenating the first number 1 and the first prime 2, we get 12 which is not prime. However, concatenating the second number 2 and the second prime 3, we get 23 which satisfies the criteria. The next possibility, 35, doesn't satisfy but 47 does. 

Writing a program that yields all the conforming primes up to ten million, yields the following select group where | represents the operation of concatenation: 
  • 2 | 3 --> 23
  • 4 | 7 --> 47
  • 12 | 37 --> 1237
  • 27 | 103 --> 27103
  • 57 | 269 --> 57269
  • 58 | 271 --> 58271
  • 85 | 439 --> 85439
  • 93 | 487 --> 93487
  • 145 | 829 --> 145829
  • 406 2791 --> 4062791
  • 591 4327 --> 5914327
  • 835 | 6421 --> 8356421
Interestingly, apart from 2, all the  \(n^{th}\) numbers are composite in the range up to 999. This investigation arose from the number associated with my diurnal age today, namely 27103. It turned out that this number is a member of OEIS A084667:


 A084667

Primes which are a concatenation of \(n\) and prime(\(n\)).   
    


For this sequence, we are only applying the first criterion. The initial members of the sequence are shown below with previous primes marked in bold:

23, 47, 613, 1237, 1759, 1861, 2383, 27103, 30113, 35149, 36151, 41179, 42181, 45197, 46199, 54251, 56263, 57269, 58271, 61283, 71353, 82421, 83431, 85439, 92479, 93487, 99523, 115631, 117643, 119653, 121661, 123677, 127709, 136769, 141811, 145829, 147853 

It can be noted that of the terms shown, the  \(n^{th}\) number in several cases is prime e.g. 1759, 2383 etc. I was interested in finding out how many primes survived once the second and third criteria were applied and 27103 survived as can be seen. 

Wednesday 14 June 2023

Kaprekar Quintuples

I've written about Kaprekar before in posts titled Kaprekar's Routine on 16th July 2021 and Birth Year Magic on 3rd June 2020. Today, the number associated with my diurnal age (27100) brought me into contact with him again via his Kaprekar Quintuples. These are numbers \(n\) with the property that the digits of \(n^5\) taken \(d\) at a time sum to \(n\) (where \(d\) is the number of digits in \(n\)).

Let's illustrate this in the case of 27100 where we take groups of five digits beginning from the rightmost digit, leaving three digits remaining on the left:$$27100^5 = 14616603103510000000000\\ 146+16603+10351+00000+00000 = 27100 $$Let's try with another number, 7776, that has four digits instead of five. Here we take groups of four digits beginning at the rightmost digit with no digits left over:$$7776^5 = 28430288029929701376 \\2843+0288+0299+2970+1376 = 7776$$The members of the sequence are (permalink showing members up to 100,000):

1, 10, 1000, 7776, 27100, 73440, 95120, 500499, 505791, 540539, 598697, 665335, 697598, 732347, 7607610, 37944478, 46945205, 54995500, 55216205, 56607166, 58106906, 63136413, 66595563, 68167738, 68807564, 69188525, 70667477, 72197730, 73197730, 74145807

These numbers constitute OEIS A171500. These numbers can also be called order-5 Kaprekar numbers and this site shows the initial members. See Table 1.


Table 1

The same site also shows order-4 Kaprekar numbers or Kaprekar quadruples where numbers are raised to the fourth power. See Table 2.


Table 2

Order-3 and order-2 Kaprekar are also shown on this site and could be referred to as Kaprekar triplets/triples and Kaprekar couplets/pairs.

The RATS Sequence Revisited

It was on Saturday, 26th September 2020, that I first wrote about the RATS sequence, the acronym standing for Reverse --> Add --> Then Sort. On that occasion I was looking at the number 26109 that is a member of OEIS A114613:


A114613

Starting numbers for which the RATS sequence has eventual period 3.      


Yesterday the number associated with my diurnal age, 27099, is the next member of that sequence. The sequence runs (permalink):

20169, 20709, 21159, 22149, 23139, 24129, 25119, 26109, 27099, 28089, 29079, 30159, 30168, 30708, 30789, 31149, 31158, 31779, 32139, 32148, 32769, 33129, 33138, 33759, 34119, 34128, 34749, 35109, 35118, 35739, 36108, 36729, 37098, 37719, 38088, 38709, 39078, 39699, ...

As can be seen, the members of this sequence are few and far between. Up to 40,000, there are only 38 terms. In the case of 27099 the progression is:

27099, 111267, 337788, 1122255, 4446666, 1111113, 2222244, 4446666

There are sequences with different periods but for most numbers the progression is infinite. See Table 1:


Table 1

The original post contains more information that I won't repeat here. Using my diurnal age today (27100) as an example, we see the divergent period-2 pattern emerging, with the red showing the progression of this period-2 pattern (permalink).

27100
22277
49999
134999
113344
555566
1111222
2333333
5566666
11222333
44444455
88889999
178888888
156777779
113344555
666677888
1444555555
167999
116677
238889
1122277
4448888
12333337
55666688
133333444
556667777
1233334444
5566667777
12333334444
55666667777
123333334444
556666667777
1233333334444
5566666667777
12333333334444
55666666667777
123333333334444
556666666667777
1233333333334444
5566666666667777

It won't be until I turn 28089 days old that I'll meet this sequence again. The Wolfram Demonstration Project also features the RATS sequence and displays the progression of terms up till the start of the period-2 pattern. See Table 2.


Table 2

Sunday 11 June 2023

Linear Relationships Between Loeschian Numbers

It all began innocently enough with my investigation of the number associated with my diurnal age today, 27097. It turns out that this number is a member of OEIS A198775: 


  A198775

Numbers having exactly four representations by the quadratic form \(x^2+xy+y^2\) with \(0 \leq x \leq y\).

We see that: $$ \begin{align} 7^2+7 \times 161+ 161^2&= 27097\\47^2 +47 \times 136+136^2&= 27097\\64^2+ 64 \times 123 +123^2&= 27097\\77^2+77 \times 112+112^2&= 27097 \end{align}$$The first member of the sequence is the famous taxi cab number 1729 and I've written about this in my post titled Loeschian Numbers on January 5th 2022.

I then decided to investigate what numbers have exactly five representations by the quadratic form \(x^2+xy+y^2\) with \(0 \leq x \leq y\). The initial numbers that satisfy this condition are 8281, 17689, 24843, 31213, 33124, 45619, 47089, 53067, 56203, 56791, 57967, 62377, 63973, ...

For example 8281 has \( (x,y) \) representations as:

(0, 91), (11, 85), (19, 80), (39, 65), (49, 56)

The sequence is not recognised by the OEIS. I then moved to numbers that have six such representations. This yielded 12103, 19747, 22477, 23569, 27391, 28861, 32851, 34447, 36309, 36673, 38857, 40033, 42679, 43771, 46501, 48412, 50323, 50869, ...

For example, 12103 has \( (x,y) \) representations as:

(2, 109), (21, 98), (27, 94), (34, 89), (49, 77), (61, 66) 

Again, this sequence is not recognised by the OEIS. I then turned to numbers that have seven such representations. This yielded 104377 and 105469 although I'm sure there are more if I extended the search.

For example, 104377 has \( (x,y) \) representations as:

(47, 297), (69, 283), (72, 281), (107, 256), (131, 237), 137, 232), (181, 192) 

Again this sequence is not recognised by the OEIS. I then turned to numbers that have eight such representation. This yielded 53599, 63973, 74347, 84721, ...

For example, 53599 has \( (x,y) \) representations as:

(3, 230) (25, 218) (43, 207) (58, 197) (85, 177) (90, 173) (102, 163) (122, 145) 

Again this sequence wasn't recognised by the OEIS but I got the following intriguing message:

Sorry, but the terms do not match anything in the table.

Your sequence appears to be: \(10374 \, x + 43225 \)

This rather shocked me but it's indeed true. I checked the factorisation of the two numbers and as can be seen they are highly factorisable:$$10374 =2 \times 3 \times 7 \times 13 \times 19\\43225=5^2 \times 7 \times 13 \times 19$$Furthermore, we have:$$ \begin{align} 10374 \times 1 + 43225 &= 53599\\10374 \times 2 + 43225 &= 63973\\10374 \times 3 + 43225 &= 74347\\10374 \times 4 + 43225 &= 84721 \end{align} $$However, using my Jupyter notebook, I extended the range of terms and found that the very next term after 84721 did not match up. The next term is 104377 but$$10374 \times 5 + 43225 =95095 \neq 104377$$Later terms however, do match up even though, term by term, the two series diverge sharply (see Figure 1) .


Figure 1

Actual Series: 

53599, 63973, 74347, 84721, 104377, 105469, 115843, 121303, 126217, 136591, 138229, 144781, 152551, 160797, 164983, 167713, 172081, 177289, 178087, 188461, 189007, 191737, 191919, 202027, 205387, 205933, 211603, 214396, 219583, 222859, 223041, 225589, 238693, 240331, 241129, 245791, 251503, 254163, 255892, 261079, 262171, 265993, 271453, 271999, 273637, 276241, 280231, 281827, 283309, 285649, 290563, 292201, 297388, 298753, 300181, 300979, 307489, 309127, 312949, 313131, 316407, 325507, 325717, 326599, 329251, 329707, 333697, 338884, 344071, 345247, 346801, 347529, 348859, 352261, 358267, 359233, 363909, 364819, 367003, 371917, 378651, 379561, 383173, 385567, 388759, 392119, 392977, 393421, 395941, 397537, 399931, 403039, 405223, 405769, 409773, 414687, 416689, 417487, 417508, 421876, 424669, 425971, 426517, 427609, 432523, 434343, 436639, 438529, 442897, 445081, 449407, 451801, 457219, 457653, 459277, 459823, 463372, 467077, 468013, 468559, 475741, 476749, 477337, 478933, 481663, 482391, 485212, 486031, 489307, 489769, 494949, 496951, 503139, 504868, 506863, 508417, 510601, 513019, 514843, 516243, 523621, 524797, 528619, 530803, 531867, 534261, 536389, 537943, 538447, 541177, 543571, 543907, 544453, 545713, 546364, 548821, 552916, 554743, 557479, 558961, 561379, 565383, 566293, 567021, 569023, 569191, 571753, 572299, 573097, 575211, 575757, 579124, 582673, 586117, 589057, 590863, 591409, 592249, 595231, 603421, 604903, 605059, 606081, 609427, 610204, 612313, 614341, 616161, 617799, 619801, 622573, 623371, 624169, 624967, 625177, 627991, 629083, 632149, 634291, 634543, 634809, 637819, 640927, 641173, 643188, 644371, 644917, 646009, 647311, 647881, 648613, 649831, 650503, 655291, 658749, 659932, 661297, 664573, 667147, 668577, 669123, 670033, 670852, 671251, 672049, 673309, 676767, 679357, 679861, 681163, 684019, 684229, 686413, 688324, 697333, 700063, 703969, 704977, 707161, 708253, 709156, 710353, 710437, 711607, 712348, 712411, 716079, 720993, 721981, 723387, 724087, 726313, 726817, 727909, 737149, 737373, 740467, 742729, 743071, 746179, 746263, 748657, 750841, 753571, 753844, 754509, 755209, 756028, 759031, 762489, 764491, 766948, 767011, 767676, 771043, 771589, 772597, 774151, 774319, 775333, 776209, 778687, 778813, 781417, 783237, 783601, 786513, 786961, 788671, 790153, 794941, 795739, 797979, 798343, 800527, 802123, 807079, 808108, 811447, 813001, 814359, 815997, 820477, 820911, 821548, 823732, 825643, 826987, 827659, 828723, 834613, 835639, 838201, 839059, 840007, 840693, 842023, 843661, 845481, 846412, 847483, 849927, 850297, 856947, 857584, 860587, 862771, 863569, 864367, 866047, 866761, 869953, 871507, 871689, 872599, 875161, 876603, 878332, 879823, 882973, 884317, 886483, 886879, 887341, 890701, 891436, 892164, 896077, 896259, 897883, 899689, 900543, 902356, 902937, 904267, 904813, 905107, 905863, 909181, 909571, 912457, 913003, 917833, 919429, 920647, 922467, 923377, 926443, 927381, 932197, 932659, 933751, 935389, 937099, 938119, 938847, 939393, 940849, 941317, 941773, 943033, 944167, 945763, 949221, 949753, 950677, 952861, 954772, 957229, 961093, 961324, 962143, 964516, 966301, 971299, 972439, 976521, 977151, 979279, 979797, 983164, 984067, 984529, 987259, 987753, 988183, 989121, 993643, 993811, 994357, 996151, 997633, 999037, 999271, 1000027, 1001091, 1002589, 1003093, 1004731, 1009489, 1016652, 1019179, 1019683, 1021657, 1023568, 1030351, 1030393, 1031401, 1032213, 1035139, 1035741, 1038331, 1042587, 1042951, 1044316, 1049503, 1051687, 1052233, 1057069, 1060423, 1061347, 1062271, 1063972, 1068249, 1079029, 1093963, 1121029, 1128673, 1151059, 1177813, 1215487, 1241023, 1246609, 1319227, 1323049, 1356901

Linear Series: 

53599, 63973, 74347, 84721, 95095, 105469, 115843, 126217, 136591, 146965, 157339, 167713, 178087, 188461, 198835, 209209, 219583, 229957, 240331, 250705, 261079, 271453, 281827, 292201, 302575, 312949, 323323, 333697, 344071, 354445, 364819, 375193, 385567, 395941, 406315, 416689, 427063, 437437, 447811, 458185, 468559, 478933, 489307, 499681, 510055, 520429, 530803, 541177, 551551, 561925, 572299, 582673, 593047, 603421, 613795, 624169, 634543, 644917, 655291, 665665, 676039, 686413, 696787, 707161, 717535, 727909, 738283, 748657, 759031, 769405, 779779, 790153, 800527, 810901, 821275, 831649, 842023, 852397, 862771, 873145, 883519, 893893, 904267, 914641, 925015, 935389, 945763, 956137, 966511, 976885, 987259, 997633, 1008007, 1018381, 1028755, 1039129, 1049503, 1059877, 1070251, 1080625, 1090999, 1101373, 1111747, 1122121, 1132495, 1142869, 1153243, 1163617, 1173991, 1184365, 1194739, 1205113, 1215487, 1225861, 1236235, 1246609, 1256983, 1267357, 1277731, 1288105, 1298479, 1308853, 1319227, 1329601, 1339975, 1350349, 1360723, 1371097, 1381471, 1391845, 1402219, 1412593, 1422967, 1433341, 1443715, 1454089, 1464463, 1474837, 1485211, 1495585, 1505959, 1516333, 1526707, 1537081, 1547455, 1557829, 1568203, 1578577, 1588951, 1599325, 1609699, 1620073, 1630447, 1640821, 1651195, 1661569, 1671943, 1682317, 1692691, 1703065, 1713439, 1723813, 1734187, 1744561, 1754935, 1765309, 1775683, 1786057, 1796431, 1806805, 1817179, 1827553, 1837927, 1848301, 1858675, 1869049, 1879423, 1889797, 1900171, 1910545, 1920919, 1931293, 1941667, 1952041, 1962415, 1972789, 1983163, 1993537, 2003911, 2014285, 2024659, 2035033, 2045407, 2055781, 2066155, 2076529, 2086903, 2097277, 2107651, 2118025, 2128399, 2138773, 2149147, 2159521, 2169895, 2180269, 2190643, 2201017, 2211391, 2221765, 2232139, 2242513, 2252887, 2263261, 2273635, 2284009, 2294383, 2304757, 2315131, 2325505, 2335879, 2346253, 2356627, 2367001, 2377375, 2387749, 2398123, 2408497, 2418871, 2429245, 2439619, 2449993, 2460367, 2470741, 2481115, 2491489, 2501863, 2512237, 2522611, 2532985, 2543359, 2553733, 2564107, 2574481, 2584855, 2595229, 2605603, 2615977, 2626351, 2636725, 2647099, 2657473, 2667847, 2678221, 2688595, 2698969, 2709343, 2719717, 2730091, 2740465, 2750839, 2761213, 2771587, 2781961, 2792335, 2802709, 2813083, 2823457, 2833831, 2844205, 2854579, 2864953, 2875327, 2885701, 2896075, 2906449, 2916823, 2927197, 2937571, 2947945, 2958319, 2968693, 2979067, 2989441, 2999815, 3010189, 3020563, 3030937, 3041311, 3051685, 3062059, 3072433, 3082807, 3093181, 3103555, 3113929, 3124303, 3134677, 3145051, 3155425, 3165799, 3176173, 3186547, 3196921, 3207295, 3217669, 3228043, 3238417, 3248791, 3259165, 3269539, 3279913, 3290287, 3300661, 3311035, 3321409, 3331783, 3342157, 3352531, 3362905, 3373279, 3383653, 3394027, 3404401, 3414775, 3425149, 3435523, 3445897, 3456271, 3466645, 3477019, 3487393, 3497767, 3508141, 3518515, 3528889, 3539263, 3549637, 3560011, 3570385, 3580759, 3591133, 3601507, 3611881, 3622255, 3632629, 3643003, 3653377, 3663751, 3674125, 3684499, 3694873, 3705247, 3715621, 3725995, 3736369, 3746743, 3757117, 3767491, 3777865, 3788239, 3798613, 3808987, 3819361, 3829735, 3840109, 3850483, 3860857, 3871231, 3881605, 3891979, 3902353, 3912727, 3923101, 3933475, 3943849, 3954223, 3964597, 3974971, 3985345, 3995719, 4006093, 4016467, 4026841, 4037215, 4047589, 4057963, 4068337, 4078711, 4089085, 4099459, 4109833, 4120207, 4130581, 4140955, 4151329, 4161703, 4172077, 4182451, 4192825, 4203199, 4213573, 4223947, 4234321, 4244695, 4255069, 4265443, 4275817, 4286191, 4296565, 4306939, 4317313, 4327687, 4338061, 4348435, 4358809, 4369183, 4379557, 4389931, 4400305, 4410679, 4421053, 4431427, 4441801, 4452175, 4462549, 4472923, 4483297, 4493671, 4504045, 4514419, 4524793, 4535167, 4545541, 4555915, 4566289, 4576663, 4587037, 4597411, 4607785, 4618159, 4628533, 4638907, 4649281, 4659655, 4670029, 4680403, 4690777, 4701151, 4711525, 4721899, 4732273, 4742647, 4753021, 4763395, 4773769

Matching Terms:

53599, 63973, 74347, 84721, 105469, 115843, 126217, 136591, 167713, 178087, 188461, 219583, 240331, 261079, 271453, 281827, 292201, 312949, 333697, 344071, 364819, 385567, 395941, 416689, 468559, 478933, 489307, 530803, 541177, 572299, 582673, 603421, 624169, 634543, 644917, 655291, 686413, 707161, 727909, 748657, 759031, 790153, 800527, 842023, 862771, 904267, 935389, 945763, 987259, 997633, 1049503, 1215487, 1246609, 1319227

54 out the 346 terms that I generated match up with the linear sequence. That's almost 20% of the terms. There's clearly more at play here than meets the eye but I don't know what it is. If we look at the list of matching terms, we find the following values for \(x\) in \(10374 \, x + 43225\) generate the terms in the sequence:

1, 2, 3, 4, 6, 7, 8, 9, 12, 13, 14, 17, 19, 21, 22, 23, 24, 26, 28, 29, 31, 33, 34, 36, 41, 42, 43, 47, 48, 51, 52, 54, 56, 57, 58, 59, 62, 64, 66, 68, 69, 72, 73, 77, 79, 83, 86, 87, 91, 92, 97, 113, 116, 123

Thus for the last term we have \(10374 \times 123 + 43225 = 1319227 \).

Tuesday 6 June 2023

Two Mystery Sequences

What if you were presented with the following sequence of terms:

9, 18, 27, 36, 45, 54, 63, 72, 99, 198, 297, 396, 495, 594, 693, 792, 999, 1998, 2997, 3996, 4995, 5994, 6993, 7992, 8082, 8172, 8262, 8352, 8442, 8532, 8622, 8712, 8802, 9999, 19998, 29997, 39996, 49995, 59994, 69993, 79992, 80982, 81972, 82962, 83952, 84942, 85932, 86922, 87912, 88902, 99999, 199998, 299997, 399996, 499995, 599994, 699993, 799992, 809982, 819972, 829962, 839952, 849942, 859932, 869922, 879912, 889902, 890802, 891702, 892602, 893502, 894402, 895302, 896202, 897102, 898002 

What is the pattern that this sequence is following? At first it looks like we are just generating multiples of 9 because we begin with 9, 18, 27, 36, 45, 54, 63, 72 but after that 99 follows and not 81. However, 99 is followed by its multiples again up to 792 = 8 x 99 after which there is a jump to 999 and the pattern repeats. The jump from the 8th multiple is always to the largest number with the same number of digits as the previous multiples. Thus from 72 we jump to 99 and from 792 we jump to 999. However, 999 then progresses to its 17th multiple, not its 8th, and then jumps to 9999 which then repeats this pattern. 

We could keep making up ad hoc rules to account for the terms of this sequence but actually they arise from a fairly simple process: 

  • start with the number 1
  • take this number, reverse it and calculate the absolute difference between the two numbers
  • if this difference is greater than zero and greater than any previous difference, then add this difference as a term of the sequence
  • proceed to the next number
All single digit numbers and even 11, because it is a palindrome, will yield a difference of zero and so no terms are added. However, once we reach 12, its reversal is 21 and the difference is 9 and so this becomes the first term of the sequence. The next number is 13 and the difference with its reversal of 31 is 18, so this difference is added to the sequence and so on. Table 1 shows the situation with the fourth column showing the factorisation of all the record differences in the range up to 100,000:


Table 1: permalink

The only such number that I'm likely to experience, via my diurnal age, is 29997. Not surprisingly, the OEIS does not recognise this sequence and I've no intention of attempting to add it.

Another interesting sequence arises if we look at the prime factors of these differences. In the first one million numbers, the prime factors that arise are as follows (arranged in ascending order and ignoring multiplicity):

2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 53, 67, 79, 101, 163, 227, 271, 307, 337, 409, 419, 439, 449, 479, 941, 1559, 2053, 2647, 2917, 3803, 5521, 7127, 22777, 23887, 49639, 49739, 49789

Again, the OEIS has nothing to say about this sequence and it would be difficult to reverse engineer this sequence. What pattern does it follow? At first it seems like the sequence of prime numbers, until we get to 41. After this, 43 and 47 are skipped and then 53 is added. Why? Anyway, nothing too profound here, just two seemingly mysterious sequences that arise from a simple process operating in the background.