Saturday, 27 June 2026

Prime Magic Squares

The number associated with my diurnal age today, \( \textbf{28209} \), is a member of OEIS A269324:


A269324
: magic sums of 3 x 3 magic squares composed of primes in an arithmetic progression.

I was interested in finding out what these primes were and how they could be arranged so I sought help from Gemini. Here was what it came up with:

To construct a 3×3 magic square of primes in an arithmetic progression for the magic sum 28209 (a term from OEIS A269324), we need to determine the central prime, find the common difference of the progression, and then map those primes to the cells of the grid. Here is the complete step-by-step breakdown of the mathematics and the final arrangement.

1. Finding the Central Prime

In any 3×3 magic square, the central cell is always the average of the magic sum. Because the magic sum (\( S \)) is the total of any given row, column, or diagonal, the center prime is exactly \( S / 3 \).

$$ \text{Center} = \frac{28209}{3} = 9403 $$

Because the 9 primes must form an arithmetic progression, the central cell of the magic square must also be the median (the 5th term) of the sorted sequence. Therefore, our arithmetic progression of primes is centered at 9403.

2. Determining the Common Difference

Let \( d \) be the common difference. Our 9 primes will take the form of \( 9403 + kd \), where \( k \) ranges from \( -4 \) to \( 4 \).

According to prime arithmetic progression properties, an arithmetic progression of \( k \) primes must have a common difference divisible by every prime \( q \le k \) (unless the progression actually begins with \( q \)). Since our sequence contains 9 primes and does not start with 2, 3, 5, or 7, the common difference \( d \) must be a multiple of their primorial:

$$ d = 2 \times 3 \times 5 \times 7 = 210 $$

By testing the multiples of 210, we can find the exact difference where all 9 resulting terms are prime:

  • \( d = 210 \) fails because the term \( 9403 - 210 = 9193 \), which is \( 29 \times 317 \).
  • \( d = 420 \) fails because \( 9403 + 420 = 9823 \), which is \( 11 \times 19 \times 47 \).
  • \( d = 630 \) fails because \( 9403 - 3(630) = 7513 \), which is \( 11 \times 683 \).
  • \( d = 840 \) succeeds.

3. The Nine Primes

Using \( d = 840 \) and our center prime of 9403, we can generate the 9 primes for the magic square by stepping out by 840 in both directions:

  • \( 9403 - 4(840) = \) 6043
  • \( 9403 - 3(840) = \) 6883
  • \( 9403 - 2(840) = \) 7723
  • \( 9403 - 1(840) = \) 8563
  • 9403 (Center)
  • \( 9403 + 1(840) = \) 10243
  • \( 9403 + 2(840) = \) 11083
  • \( 9403 + 3(840) = \) 11923
  • \( 9403 + 4(840) = \) 12763

4. Arranging the Magic Square

To arrange these into a valid 3×3 magic square, we map our ordered sequence to the classic Lo Shu magic square structure. In the traditional 1–9 Lo Shu square, the numbers are placed so that opposites balance out across the center (5). Substituting our 1st through 9th primes directly into the equivalent positions of the Lo Shu configuration yields the following layout:

11923 6043 10243
7723 9403 11083
8563 12763 6883

Every row, column, and main diagonal in this grid perfectly sums to 28209. Keep in mind that any of the 8 standard symmetries (rotations or reflections) of this exact grid will also produce a valid magic square for this progression.

Thursday, 25 June 2026

Reverse Engineering Part 3

In my previous post, Reverse Engineering Part 2, I ended up being quite satisfied with the reverse engineering that created as output an homogenous linear recurrence relation of order 3 after input of any positive integer greater than 9. I used 28206 and 28207 as examples to illustrate the process.

This got me thinking about creating as output an homogenous linear recurrence relation of order 2 after input of any positive integer greater than 9. I explained in my post Reverse Engineering Part 1 that Gemini's algorithm had failed when attempting this. I was trying to get Gemini to create the following:$$ \begin{align} &\text{a}(n)=p \times \text{a}(n-1)+q \times \text{a}(n-2) \\ &\text{where} -9 \leq p,q \leq 9 \text{ with } p \neq 0 \text{ and } q \neq 0 \\ &\text{ and } 0 \leq \text{a}(n-1), \text{a}(n-2) \leq 9 \end{align}$$So I asked Gemini to relax the conditions by specifying that \( |p + q|\) should be as small as possible. When applied to 28207 this produced values \(p=39\) and \(q=-38\). Not quite what I wanted. So in the end I specified that \(|p^2+q^2+a(0)^2+a(1)^2|\) should be as small as possible. Applied to 28206, this was the result (permalink):

Target Number: 28206
--------------------------------------------------
Constants found: p = 13, q = 1
Constraint check: Minimum p^2 + q^2 + a(0)^2 + a(1)^2 = 395
Seed numbers:    a(0) = 9, a(1) = 12
--------------------------------------------------
Sequence progression:
  a(0) = 9
  a(1) = 12
  a(2) = 165
  a(3) = 2157
  a(4) = 28206
--------------------------------------------------
Comma-separated sequence:
9, 12, 165, 2157, 28206

Applied to 28207, this was the result (permalink):

 Target Number: 28207

--------------------------------------------------
Constants found: p = 6, q = 5
Constraint check: Minimum p^2 + q^2 + a(0)^2 + a(1)^2 = 231
Seed numbers:    a(0) = 11, a(1) = 7
--------------------------------------------------
Sequence progression:
  a(0) = 11
  a(1) = 7
  a(2) = 97
  a(3) = 617
  a(4) = 4187
  a(5) = 28207
--------------------------------------------------
Comma-separated sequence:
11, 7, 97, 617, 4187, 28207

Overall I'm quite happy with these sequences. All terms are positive, the coefficients and seed values are not large and the terms increase steadily toward their targets, avoiding any wild gyrations. I have incorporated this program into my daily number analysis. 

Reverse Engineering Part 2

In my previous post Reverse Engineering Part 1, I had specified to Gemini that I wanted \(p + q + r \) to be the minimum possible within the specifications that each of these coefficients were to be between -9 and -9 inclusive. I was thinking in terms of the sum getting as close to zero as possible forgetting that the minimum possible sum would be -27. That's why I was getting coefficients in the output that were all negative. The algorithm was doing what I'd asked of it! What I should have instructed Gemini to do was to take the absolute value of \(p+q+r\). So to summarise, our starting point is:$$ \begin{align} &\text{a}(n)=p \times \text{a}(n-1)+q \times \text{a}(n-2) + r \times \text{a}(n-2)\\ &\text{with } -9 \leq p,q,r \leq 9, 0 \leq \text{a}(2), \text{a}(1),\text{a}(0) \leq 9 \\ &\text{and } |p+q+r| \text{ as close to zero as possible} \end{align}$$Having gotten Gemini to modify the algorithm, the result for 28206 becomes :$$ \begin{align} &\text{a}(n)=5 \times \text{a}(n-1)-7 \times \text{a}(n-2) + 2 \times \text{a}(n-2)\\ &a(0) = 2, a(1) = 2, a(2) = 6\end{align}$$The full details are (permalink):

Target Number: 28206
------------------------------
Constants found: p = 5, q = -7, r = 2
Constraint check: Minimum |p + q + r| = 0 (Actual Sum = 0)
Seed numbers:    a(0) = 2, a(1) = 2, a(2) = 6
------------------------------
Sequence progression:
  a(0) = 2
  a(1) = 2
  a(2) = 6
  a(3) = 20
  a(4) = 62
  a(5) = 182
  a(6) = 516
  a(7) = 1430
  a(8) = 3902
  a(9) = 10532
  a(10) = 28206
------------------------------
Comma-separated sequence:
2, 2, 6, 20, 62, 182, 516, 1430, 3902, 10532, 28206

This is a longer sequence than previously (2, 4, 2, -48, 408, -3390, 28206) but it has no negative members and is free of the wild gyrations that characterise the former. Similarly for 28207, we have (permalink):$$ \begin{align} &\text{a}(n)=5 \times \text{a}(n-1)+4 \times \text{a}(n-2) -8 \times \text{a}(n-2)\\ &a(0) = 1, a(1) = 1, a(2) = 7\end{align}$$The full results are (permalink):

Target Number: 28207
------------------------------
Constants found: p = 5, q = 4, r = -8
Constraint check: Minimum |p + q + r| = 1 (Actual Sum = 1)
Seed numbers:    a(0) = 1, a(1) = 1, a(2) = 7
------------------------------
Sequence progression:
  a(0) = 1
  a(1) = 1
  a(2) = 7
  a(3) = 31
  a(4) = 175
  a(5) = 943
  a(6) = 5167
  a(7) = 28207
------------------------------
Comma-separated sequence:
1, 1, 7, 31, 175, 943, 5167, 28207

This is shorter than the previously calculated sequence (3, 5, 1, -73, 243, -323, -311, 2207, -3445, -3595, 27729, -51001, -16797, 304365, -658279, 28207) and again it has no negative members and is free of the wild gyrations that characterise the former. So, a lesson learned. I've modified my daily number analysis algorithm accordingly. 

Wednesday, 24 June 2026

Reverse Engineering Part 1

I have a sub-program in my daily number analysis program that will work backwards to find Fibonacci seed numbers that will generate a sequence of terms that leads to my daily number. For example, today I am 28206 days old, and my sub-program generates the following output:

Fibonacci Sequence: Smallest Starting Pair for Target 28206
Starting numbers: a = 126, b = 118
Sequence length to target: 13
Full sequence: [126, 118, 244, 362, 606, 968, 1574, 2542, 4116, 6658, 10774, 17432, 28206]

This can be expressed as:$$ \begin{align} \text{a}(n)=\text{a}(n-1) + \text{a}(n-2)  \\ \text{where } \text{a}(0)=126 \text{ and } \text{a}(1)=118 \end{align}$$These large initial values disturbed me and I wondered if the addition of coefficients \(p\) and \(q\) might reduce the size of the seed numbers required.

I asked Gemini the following:

I would like you to write a program in SageMath that will accept any positive integer \(n > 9\) as input and work backwards to find two seed numbers \( \text{a}(0) \text{ and } \text{a}(1)\) that, combined with constants \(p\) and \(q\), will lead to \(n\) via a Fibonacci-like sequence generated by \( \text{a}(n) = p \times \text{a}(n-1) + q \times \text{a}(n-2)\). The restrictions are that the seed numbers must be between 1 and 9 and the constants \(p\) and \(q\) must also be between -9 and 9.  In the case of more than one combination of constants and seed numbers being found, the criterion is that \(p + q\) should be the minimum possible. The default value for n can be taken as 28206. The program should run in SageMathCell and a Jupyter notebook. The output should show the sequence as it progresses from its starting seed numbers to the final number n. The members of the sequence should also be displayed as comma-separated values.

Unfortunately these restraints proved too restrictive and so I turned to Tribonacci numbers looking for three seed numbers, each between 0 and 9, and three constants \(p, q, r\), each lying between -9 and 9 so that:$$\text{a}(n) = p \times \text{a}(n-1) + q \times \text{a}(n-2) + r \times \text{a}(n-3) $$This proved more productive with Gemini creating the program and producing the following output (permalink):

Target Number: 28206
------------------------------
Constants found: p = -9, q = -6, r = -3
Constraint check: Minimum p + q + r = -18
Seed numbers:    a(0) = 2, a(1) = 4, a(2) = 2
------------------------------
Sequence progression:
  a(0) = 2
  a(1) = 4
  a(2) = 2
  a(3) = -48
  a(4) = 408
  a(5) = -3390
  a(6) = 28206
------------------------------
Comma-separated sequence:
2, 4, 2, -48, 408, -3390, 28206

For me, this is a more satisfactory output with the recursion looking like this: $$ \begin{align} &\text{a}(n) = -9 \times \text{a}(n-1) -6 \times \text{a}(n-2) -3 \times \text{a}(n-3) \\ &\text{with } \text{a}(0)=2, \text{a}(1)=4, \text{a}(2)=2 \end{align}$$What we have here is an homogenous linear recurrence relation of order 3 with coefficients and boundary conditions (seed values) as shown. The sequence is defined by two tuples: the coefficient tuple C and initial value tuple I and written as (C, I). In the example just shown, the representation would be:$$((-9, -6, -3), (2,4,2))$$Let's look at the next number 28207 characterised by ((-4, -9, -8), (3, 5, 1)):

Target Number for Reverse Tribonacci: 28207
------------------------------
Constants found: p = -4, q = -9, r = -8
Constraint check: Minimum p + q + r = -21
Seed numbers:    a(0) = 3, a(1) = 5, a(2) = 1
------------------------------
Sequence progression:
  a(0) = 3
  a(1) = 5
  a(2) = 1
  a(3) = -73
  a(4) = 243
  a(5) = -323
  a(6) = -311
  a(7) = 2207
  a(8) = -3445
  a(9) = -3595
  a(10) = 27729
  a(11) = -51001
  a(12) = -16797
  a(13) = 304365
  a(14) = -658279
  a(15) = 28207
------------------------------
Comma-separated sequence:
3, 5, 1, -73, 243, -323, -311, 2207, -3445, -3595, 27729, -51001, -16797, 304365, -658279, 28207

Figure 1 shows the trajectory of the sequence which begins to fluctuate wildly but the negative by negative multiplication quickly homes in on the target number (28207).

Figure 1

I've now incorporated this information into my daily number analysis.

The Standard Cipher

I like the Standard or English Extended Cipher because of its similarity those of the ancient languages. Here I've applied it to my name leaving out my middle name which is rarely used except in official documents:


Source

This number (\( \textbf{761}\)) is prime with the following properties:

  • it is an emirp because \(167\) is prime
  • it is a 4\(k\)+1 prime such that \(761=19^2+20^2\)
  • it is a Sophie Germain prime since \(761 \times 2 + 1 = 1523\) is prime
  • it is the \(20\)th-centered square number
  • it can be rendered as a digit equation: \(7 = 6+1\)

My birth name is also prime (\( \textbf{733}\)) with the following properties:

  • it is an emirp because \(337\) is prime
  • it is a 4\(k\)+1 prime such that \(733 = 2^2 + 27^2\)
  • it is a balanced prime because it is an equal distance from the previous prime \(727\) and the next prime \(739\)
  • it is a right truncatable prime since \(733 \rightarrow 73 \rightarrow 7 \)


Source

John Reeves was my name for the first 25 years of my life but from age 26 onwards I was known as Sean Reeves. These two personal primes, \( \textbf{733}\) and \( \textbf{761}\), can be added to the two other personal primes of mine related to my date of birth. These are \( \textbf{3449} \) (3rd of the 4th 49 is what I would say back in the day when asked for my date of birth) and the condensed form of this number: \( \textbf{349}\).

I've written about this topic, Gematria, in two earlier posts, specifically:

Number Base Permutations

There are some numbers that have the same digits but in a different order when converted to another number base. Take 10144 as an example:$$10144_{10}= 41401_7$$The five digit numbers from 10000 to 40000 with this property are as follows (permalink):

10144, 10235, 10342, 10453, 10542, 11425, 11750, 12415, 12450, 12564, 12651, 13045, 13245, 13260, 13402, 13534, 13620, 14610, 15226, 15643, 15680, 16121, 16255, 16273, 16546, 16633, 18291, 19463, 19730, 21322, 21753, 21763, 21835, 23146, 23568, 24871, 25061, 25169, 26804, 26931, 29103, 29610, 30189, 30576, 31112, 31457, 31481, 32321, 32348, 34179, 34582, 35001, 35024, 35081, 35228, 35731, 36417, 37465, 38276

The table below shows the full details for the above numbers. As can be seen, they are not that frequent in the given range.

Results for range: 10000 to 40000
Decimal Number     | Base b Representation  | Base
-------------------------------------------------------
10144              | 41401                  | 7
10235              | 15032                  | 9
10342              | 42103                  | 7
10453              | 15304                  | 9
10542              | 42510                  | 7
11425              | 45211                  | 7
11750              | 17105                  | 9
12415              | 51124                  | 7
12450              | 51204                  | 7
12564              | 51426                  | 7
12651              | 51612                  | 7
13045              | 53014                  | 7
13245              | 53421                  | 7
13260              | 20163                  | 9
13402              | 20341                  | 9
13534              | 54313                  | 7
13620              | 20613                  | 9
14610              | 60411                  | 7
15226              | 62251                  | 7
15643              | 63415                  | 7
15680              | 10865                  | 11
16121              | 11126                  | 11
16255              | 65251                  | 7
16273              | 37621                  | 8
16546              | 66145                  | 7
16633              | 66331                  | 7
18291              | 12819                  | 11
19463              | 13694                  | 11
19730              | 13907                  | 11
21322              | 32221                  | 9
21753              | 52371                  | 8
21763              | 32761                  | 9
21835              | 32851                  | 9
23146              | 16432                  | 11
23568              | 35286                  | 9
24871              | 12487                  | 12
25061              | 12605                  | 12
25169              | 12695                  | 12
26804              | 40682                  | 9
26931              | 19263                  | 11
29103              | 10329                  | 13
29610              | 10629                  | 13
30189              | 10983                  | 13
30576              | 73560                  | 8
31112              | 11213                  | 13
31457              | 75341                  | 8
31481              | 11438                  | 13
32321              | 22313                  | 11
32348              | 48332                  | 9
34179              | 17943                  | 12
34582              | 52384                  | 9
35001              | 53010                  | 9
35024              | 24350                  | 11
35081              | 53108                  | 9
35228              | 53282                  | 9
35731              | 13357                  | 13
36417              | 13764                  | 13
37465              | 56347                  | 9
38276              | 26837                  | 11

Note that the bases range from 7 to 13. While this sequence does not occur in the OEIS, some subsets do. For example, OEIS  A037440:


 A037440: positive numbers having the same set of digits in bases 7 and 10.

Sunday, 21 June 2026

Numbers Within Numbers

Let's formalise the concept of internal digits. Take a number like 28211. It's prime but we remove the leftmost digits (2) and the rightmost digit (1), we are left with the number 821. This the number within a number and it happens to be also prime. It is thus a member of OEIS A069686:


 A069686: primes whose internal digits form a prime.

The members of this sequence from 28000 to 40000 are (permalink):

28097, 28099, 28111, 28211, 28219, 28277, 28279, 28297, 28393, 28537, 28571, 28573, 28579, 28591, 28597, 28631, 28771, 28813, 28817, 28837, 28871, 28879, 29077, 29191, 29297, 29411, 29473, 29531, 29537, 29671, 29717, 29833, 29837, 29917, 30029, 30059, 30071, 30113, 30119, 30133, 30137, 30139, 30197, 30293, 30313, 30319, 30431, 30539, 30593, 30671, 30677, 30713, 30839, 30893, 30971, 30977, 31013, 31019, 31033, 31039, 31079, 31091, 31139, 31271, 31277, 31319, 31379, 31391, 31393, 31397, 31511, 31513, 31517, 31573, 31793, 31799, 31817, 31973, 31991, 32117, 32119, 32233, 32237, 32297, 32299, 32411, 32413, 32573, 32579, 32633, 32693, 32713, 32717, 32719, 32771, 32779, 32831, 32833, 32839, 32933, 32939, 33071, 33073, 33113, 33119, 33179, 33311, 33317, 33377, 33479, 33493, 33533, 33599, 33679, 33739, 33791, 33797, 33893, 34019, 34211, 34213, 34217, 34313, 34319, 34337, 34439, 34499, 34613, 34631, 34673, 34679, 34871, 34877, 34913, 34919, 35099, 35419, 35573, 35771, 35879, 35933, 35993, 35999, 36011, 36013, 36017, 36073, 36131, 36137, 36191, 36313, 36319, 36433, 36473, 36479, 36599, 36739, 36779, 36833, 36913, 36919, 37013, 37019, 37097, 37199, 37273, 37277, 37337, 37339, 37397, 37511, 37517, 37571, 37573, 37579, 37619, 37691, 37693, 37699, 37871, 37879, 38113, 38119, 38219, 38231, 38237, 38239, 38273, 38299, 38393, 38593, 38639, 38833, 38839, 38873, 39079, 39113, 39119, 39191, 39199, 39293, 39371, 39373, 39419, 39671, 39679, 39719, 39779, 39839, 39971, 39979

We can modify the algorithm to search for square numbers within square numbers. For example, \(144 = 12^2\) and its internal digit \(4 = 2^2\) and so it is a member of OEIS A069701:


 A069701: squares with internal digits also forming a square > 0.


The members up to 40000 are few and far between: 

144, 196, 441, 841, 1369, 3364, 4096, 5041, 8649, 10816, 11449, 20164, 38416.

So the takeaway from this is that every \(n\) digit number has an (\(n-2\)) digit number inside of it provided \(n>2\) and sequences can be developed by relating this internal number to the larger number of which it forms a part.

Let's consider numbers that are biprime and whose internal digits also form a biprime. Take 28189 as an example:$$ \begin{align} 28189 &= 7 \times 4027 \\ 818 &= 2 \times 409 \end{align}$$These sorts of numbers are not listed in the OEIS. 

Similarly for triprimes. Take 28055 as an example:$$ \begin{align} 28055 &= 5 \times 31 \times  181\\805 &= 5 \times 7 \times 23 \end{align}$$Of course we could consider numbers within numbers within numbers etc. but given that I'm mainly examining five digit numbers less than 40000, I'll leave off at numbers within numbers. Of course, these relationships between numbers and their respective internal numbers only apply with certainty in the number base under consideration (base 10 so far in this post). Take our earlier example of 28211 and its internal number of 821. Both are prime. Let's change to base 9:$$ \begin{align} 28211_{10} &= 42625_9 \rightarrow 265_9 \text{ as its internal number} \\ 265_9 &= 218_{10} \text{ which is clearly not prime} \end{align} $$Primeness is base independent and if a number is not prime in a certain base then it is not prime in any base. However, the inner number while not prime in base 10 may be prime if regarded as a number in another base. Let's illustrate this with 28019. It is a prime in base 10 where the inner number, 801, is divisible by 3. However, we can note the following:$$ \begin{align} 801_{12} &= 1153_{10} \text{ which is prime}\\801_{15} &= 1801_{10} \text{ which is prime} \end{align} $$I've incorporated the search for the following types of numbers into my number analysis algorithm so that the following types of numbers can be identified:
  • prime number whose internal number is also prime in any base from 2 to 16
  • biprime number whose internal number is also prime using base 10 only
  • triprime number whose internal number is also triprime using base 10 only
  • square number whose internal number is also square using base 10 only