Monday, 17 November 2025

Testing AI

I thought I might challenge AI to guess the next number in a given sequence. This was my query:

Can you propose what the next number in this sequence of numbers might be and explain your reasoning$$1, 3, 7, 13, 7, 31, 43, 19, 73, 13, 37, \dots$$First up I asked Grok and got a rather curious response:

Uh-oh, too much information for me to digest all at once. You know, sometimes less is more!

That wasn't much help so I turned to Gemini and ChatGPT. They both accepted the challenge and tried their best but neither came up with anything convincing. Finally I gave the latter the following clue:

I'll give a clue. The numbers are generated by a simple quadratic function (using the integers 0, 1, 2, 3 , ... progressively as input) that collapses composite numbers when they appear according to a simple division rule. 

 Nice clue — that nails it.

The quadratic is \(f(n)=n^2+n+1\) for integer inputs \(n=0,1,2,\dots \). 

The collapse rule: whenever \(f(n) \) is composite, divide it by its smallest prime factor (and repeat if necessary) until the result is prime.

Checking the given terms (I'll show \(n\) \( \rightarrow \) raw \(f(n)\) \( \rightarrow \) collapsed result):

  • \(n=0: f=0^2+0+1=1 \rightarrow 1\)

  • \(n=1: f=1^2+1+1=3 \rightarrow 3\)

  • \(n=2: f=4+2+1=7 \rightarrow 7 \)

  • \(n=3: f=9+3+1=13 \rightarrow13 \)

  • \(n=4: f=16+4+1=21 \rightarrow 21/3=7 \)

  • \(n=5: f=25+5+1=31 \rightarrow 31\)

  • \(n=6: f=36+6+1=43 \rightarrow 43 \)

  • \(n=7: f=49+7+1=57 \rightarrow 57/3=19 \)

  • \(n=8: f=64+8+1=73 \rightarrow 73\)

  • \(n=9: f=81+9+1=91 \rightarrow 91/7=13 \)

  • \(n=10: f=100+10+1=111 \rightarrow 111/3=37\)

All match your sequence.

Now the next input:$$n=11: f(11)=121+11+1=133 \rightarrow 133/7 = 19$$ So the next number in the sequence is 19.

So a little clue and ChatGPT, as it said, nailed it. This was just a little experiment to see what how AI would handle a problem that is actually quite challenging. The sequence is NOT listed in the OEIS by the way.

I challenged ChatGPT to come with a similar challenge and this is what it generated:

Could you propose a similar but different challenge. You should try to be creative and innovative but adhering to the general algorithm, namely generate a sequence of numbers according to a definite rule but modify certain numbers according to another definite rule whenever they satisfy a certain preestablished criterion. Go for it.

Nice — here’s a fresh puzzle in the same spirit as yours: a definite generating rule (a simple quadratic) plus a deterministic “collapse” rule that kicks in whenever the raw value meets a criterion.

I had to take a screenshot of the puzzle as copying and pasting introduces tedious formatting challenges.

Sunday, 16 November 2025

The Universe of Catalan Numbers

 I uploaded two of my posts to NotebookLM. The posts were:
The former post was in fact only my third to Mathematical Meanderings and was made over ten years ago now (shortly after I retired at the age of 66). NotebookLM suggested "The Universe of Catalan Numbers" as a title so I've kept it. Here is the URL of the video.


NotebookLM again does a pretty good job at jazzing up the content and making it interesing. It does make an error early on as I explained in my comments to the video:
This video was generated by NotebookLM based on two posts from my mathematical blog, namely Catalan Numbers and Motzkin Numbers. These two posts are my own and AI was not used in their creation. The video doesn't quite get everything right. For example, it says at the outset that \(24285\) is a Catalan number. In fact \(24285\) is NOT a Catalan number but rather the residue after we divide the 15th Catalan number \(9694845\) by \(2^{15}\) as I explain my blog post. Apart from this, the video does a reasonable job of summarising the content of the two blog posts.

This is now the second video I've created from my blog posts and I'll sure I'll continue to generate more.

Thursday, 13 November 2025

Claude to the Rescue

The number 27983, associated with my diurnal age today, has a property than confers it membership in OEIS A335752: the lexicographically earliest sequence of primes, each two of which sum to a triprime. The sequence begins: 3, 5, 47, 239, 3023, 27983, 53231, ... so let's confirm that these numbers satisfy using 3 as a starting point:
  • \(3 + 5 = 8 =2^3\)
  • \(3 + 47 = 50 = 2 \times 5^2\)
  • \(3 + 239 = 242 = 2 \times 11^2 \)
  • \(3 + 3023 = 3026 = 2 \times 17 \times 89 \)
  • \(3+27983 = 27986 = 2 \times 7 \times 1999\)


The sums above are all triprimes and we will find that any number in the list paired with any other number will produce a triprime. The code for this was included in the OEIS comments but was in Mathematica. I got Gemini to convert it to Python code and then Grok but in both cases the primeomega function was misunderstood with both claiming that primeomega(12) =2 and not 3. 

I didn't fully understand the Python code and was looking to Gemini and then Grok to explain it to me. It was only Claude that succeeded to my satisfaction. Here is the code followed by Claude's explanation. I think Claude will be my go to resource for anything to do with coding.

from sympy import nextprime, primeomega
ps = [3]
for _ in range(10):
    p = nextprime(ps[-1]) 
    while not all(primeomega(x + p) == 3 for x in ps):
        p = nextprime(p)
    ps.append(p)
print(ps)

I'd be happy to explain this code line by line! This code generates a sequence of prime numbers with a special property.

Code Breakdown

from sympy import nextprime, primeomega

Imports two functions from SymPy:
  • nextprime(\(n\)): Returns the next prime number greater than \(n\)
  • primeomega(\(n\)): Returns the total number of prime factors of \(n\) (counting multiplicity). For example, primeomega(12) = 3 because 12 = 2² × 3 (two 2's and one 3)
ps = [3]

Initializes the sequence with the first prime number 3. This list will store our special sequence of primes.

for _ in range(10):

Loops 10 times to find 10 more primes (so we'll have 11 total including the initial 3). The underscore _ is used when we don't need the loop variable.

p = nextprime(ps[-1])

Gets the next prime after the last element in our list. 
  • ps[-1] accesses the last element of the list
  • Initially, this gives nextprime(3) = 5
  • This is our candidate prime to add to the sequence
while not all(primeomega(x + p) == 3 for x in ps):
    p = nextprime(p)

This is the key part! It checks if the candidate prime \(p\) satisfies a special condition:
  • For every number \(x\) already in our list ps
  • The sum \(x + p\) must have exactly 3 prime factors (counting multiplicity)
  • If this condition fails for any \(x\), we move to the next prime candidate
  • This continues until we find a prime where all sums have exactly 3 prime factors
ps.append(p)

Adds the qualified prime to our sequence once it passes the test.

print(ps)

Prints the final sequence** of primes.

Example Walkthrough

Let's trace the first iteration:
1. Start with ps = [3]
2. Try p = 5: Check if 3 + 5 = 8 = 2³ has 3 prime factors ✓ (yes, three 2's)
3. Add 5 to list: ps = [3, 5]
4. Try p = 7: Check 3 + 7 = 10 = 2 × 5 (only 2 factors) ✗
5. Try p = 11: Check 3 + 11 = 14 = 2 × 7 (only 2 factors) ✗
6. Continue until finding a prime that works with both 3 and 5...

This creates a sequence where each new prime maintains the property that when added to any previous prime in the sequence, the result always has exactly 3 prime factors!

*************************

Now if we change the condition to primeomega = 2, we get the following sequence: 3, 7, 19, 139, 859, 8179, 173059, ... where it can be seen there is a big jump from 8179 to 173059. Testing this out using 3 again we see that:
  • \(3+7=10=2 \times 5\)
  • \(3+19=22=2 \times 11\)
  • \(3+139=142=2 \times 71\)
  • \(3+859=862=2 \times 431\)
  • \(3+8179=8182=2 \times 4091\)
  • \(3+173059=173062=2 \times 86531\)
The sequence is included in the OEIS as A113875: slowest growing sequence of primes having the prime-pairwise-average property: if i<j, (a(i)+a(j))/2 is prime. This makes sense in that 2 seems to be the common factor is all of the sums. 

The sequence with additional (very large) terms looks like this:
3, 7, 19, 139, 859, 8179, 173059, 1026199, 1827139, 15828679, 13187242759, 18732483199, 912492556939, 9130567625119

When we set primeomega = 4 we get the following sequence: 3, 13, 137, 1193, 4373, 26017, 33889, 495433, ... which is NOT listed in the OEIS. Again let's use 3 as our test number:
  • \(3+13=16=2^4\)
  • \(3+137=140=2^2 \times 5 \times 7\)
  • \(3+1193=1196=2^2 \times 13 \times 23\)
  • \(3+4373=4376=2^3 \times 547\)
  • \(3+26017=26020=2^2 \times 5 \times 1301\)
  • \(3+33889=33892=2^2 \times 37 \times 229\)
  • \(3+495433=495436=2^2 \times 29 \times 4271\)
That's probably a good place to stop.

Tuesday, 11 November 2025

From Blog Post To YouTube Video

The idea occurred to me to save one of my blog posts as a PDF and then upload it to NotebookLM. I then generated a video overview which looked surprisingly good I thought. The blog post in question was Free Free Fibonacci Sequences from July 18th 2021. Here is the video:


I have hundreds of blog posts and I've always wanted to highlight some of them and this seems an excellent way of doing so. I was lazy to go to the trouble of creating a video but if it can be done for you then why not? I'd done all the hard work to create the post in the first place and NotebookLM is taking that content and presenting in a visually interesting way.

I'm looking forward to taking some of my other blog posts and converting them to video. I think I'll keep to the Fibonacci theme in the short term as I have several other videos on this subject that I've made over the years. In fact I have over ten years of blog posts so there's no shortage of material to draw on.

Thursday, 6 November 2025

Passcodes and Repeated Digits

The content in this post is taken from this video on the YouTube channel MindYourDecisions. Figure 1 shows if the digits of a four digit code are known, there are 24 possibilites of the code contains four distinct digits but 36 possibilities if the code contains only three digits (with one digit repeated).


Figure 1

If no digits are repeated, then there are:$$4! = 4 \times 3 \times 2 \times 1 =24 \text{ possibilities}$$However if one digit is repeated then we have:$$ \frac{4!}{2!} \times 3 = 36 \text{ possibilities}$$What happens with a six digit passcode when we know the digits but not the order. If six digits are used, then we have:$$6! = 6 \times 5 \times 4 \times 3 \times 2 \times 1  = 720 \text{ possibilities}$$However, if one digit is repeated then we have:$$ \frac{6!}{2!} \times 5 =1800 \text{ possibilities: see Figure 2}$$

Figure 2

The formulae in general for distinct digits versus one repeated digit are:$$ n! \leftarrow \text{ versus } \rightarrow \frac{(n-1) \times n!}{2}$$Once we have \(n \geq 4\) then \( (n-1)/2 \) is greater than 1 and so the single repeated digit passcode will always yield more possibilities than the distinct digits. What about repeating more than one digit? 

Figure 3 shows the situation for six digit passcodes where it can be seen that one repeated digit yields the most possibilities:


Figure 3

However, for a seven digit posscode, using five distinct digits (with two digits repeated) yields the most possibilities. See Figure 4.


Figure 4

The video referenced earlier concludes with a mention of the general case and a rather formidable formula that I won't go into here.

Sunday, 2 November 2025

Palindromic Day 27972

Today is palindromic day 27972 and the last palindromic day of the current millenium. The next palindromic day will occur in the new millenium and will 28082, one hundred and ten days from now.

My first observation is that the digits on either side of the central 9 also add to 9 to give a 9 - 9 - 9 pattern with 9 being the arithmetical digital root as well. This is the first and last time that such a triple pattern will occur in the current millenium. It cannot occur in the next two millenia (2 8 x 8 2 and 2 9 x 9 2) because the digits on either side of the central digit add to 10 and 11 respectively. So already 27972 is rather special. 

27972 is also a member of OEIS A344422: palindromes having more divisors than all smaller palindromes. The table below lists the initial members of this sequence and it can be seen that 27972 has a record 48 divisors.

  number   factorisation        divisors

  1        1                    1
  2        2                    2
  4        2^2                  3
  6        2 * 3                4
  44       2^2 * 11             6
  66       2 * 3 * 11           8
  252      2^2 * 3^2 * 7        18
  2112     2^6 * 3 * 11         28
  2772     2^2 * 3^2 * 7 * 11   36
  6336     2^6 * 3^2 * 11       42
  27972    2^2 * 3^3 * 7 * 37   48
  48384    2^8 * 3^3 * 7        72

27972 is also a member of OEIS A020485: least positive palindromic multiple of \(n\), or 0 if none exists. Here are the multiples for the initial values of \(n\).

  count   n       multiple
  1       1       1
  2       2       1
  3       3       1
  4       4       1
  5       5       1
  6       6       1
  7       7       1
  8       8       1
  9       9       1
  10      0       0
  11      11      1
  12      252     21
  13      494     38
  14      252     18
  15      525     35
  16      272     17
  17      272     16
  18      252     14
  19      171     9
  20      0       0
  21      252     12
  22      22      1
  23      161     7
  24      696     29
  25      525     21
  26      494     19
  27      999     37
  28      252     9
  29      232     8
  30      0       0
  31      434     14
  32      2112    66
  33      33      1
  34      272     8
  35      525     15
  36      252     7
  37      111     3
  38      494     13
  39      585     15
  40      0       0
  41      656     16
  42      252     6
  43      989     23
  44      44      1
  45      585     13
  46      414     9
  47      141     3
  48      2112    44
  49      343     7
  50      0       0
  51      969     19
  52      676     13
  53      212     4
  54      27972   518
  55      55      1
  56      616     11
  57      171     3
  58      232     4
  59      767     13
  60      0       0
  61      26962   442

27972 requires 13 steps to reach the palindrome 4964444694 under the Reverse and Add algorithm. 

27972 is a decagonal or ten-sided number and is the 84th decagonal number and the second non-trivial palindromic decagonal number after 232. See Figure 1 where 232 is shown but not 27972.


Figure 1: source

27972 is a member of OEIS A356854: palindromes that can be written in more than one way as the sum of two distinct palindromic primes. In the case of 27972 we have:

10501 + 17471 = 27972
11311 + 16661 = 27972
11411 + 16561 = 27972
12421 + 15551 = 27972

Tuesday, 28 October 2025

Prime Number Spiral

The number associated with my diurnal age today is a prime number: 27967 and it has the property that it is on the north spoke of a prime number spiral that begins as shown in Figure 1.


Figure 1: source

I thought it might be an interesting challenge for Gemini to write the Python code to generate this spiral up to the largest prime below 40000. To cut a long story short, Gemini failed miserably despite several attempts to improve the code. Grok on the other hand succeeded on its first try although it did time out several times and needed to be reconnected. However, it got the job done and the result is shown in Figure 2 (link to Grok).


Figure 2: code

The formatting is excellent as can be seen in the detail shown in Figure 3 that was taken from Figure 2:


Figure 3: detail from Figure 2

So Gemini proved to be not up to the task despite my persevering with additional prompts whereas Grok succeeded on its first attempt. A lesson learned.