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!

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.

Saturday, 25 October 2025

Prime Factor Fibonacci

A recent number, 27960, associated with my diurnal age has an interesting property if you look at the prime factors more closely:$$27960=2^3 \times 3 \times 5 \times 233$$Let's ignore multiplicity and look at the sum of digits of each distinct prime factor. The 2, 3 and 5 remain the same but 233 becomes 8 and the sequence of prime factors then becomes:$$2, 3, 5, 8$$This is the Fibonacci sequence. How many numbers with four prime factors (ignoring multiplicity) have this property. Well, in the range up to 40000, it turns out that there are 115. These numbers are (permalink):

510, 1020, 1530, 1590, 2040, 2130, 2550, 3060, 3180, 3210, 4080, 4260, 4590, 4770, 5100, 6120, 6360, 6390, 6420, 6990, 7314, 7530, 7650, 7950, 8160, 8520, 8670, 9180, 9540, 9630, 9798, 10200, 10650, 12240, 12720, 12750, 12780, 12840, 12930, 13038, 13770, 13980, 14310, 14628, 14766, 15060, 15090, 15300, 15630, 15900, 16050, 16320, 17040, 17085, 17340, 17466, 18360, 19080, 19170, 19260, 19596, 20400, 20970, 21030, 21300, 21942, 22590, 22950, 23850, 24480, 25440, 25500, 25560, 25680, 25860, 26010, 26076, 26322, 27540, 27960, 28620, 28890, 29256, 29394, 29532, 30120, 30180, 30600, 31260, 31800, 31830, 31950, 32100, 32154, 32637, 32640, 34080, 34530, 34638, 34680, 34932, 34950, 35445, 35511, 36690, 36720, 37650, 38160, 38250, 38340, 38520, 38790, 39114, 39192, 39750

Lets consider the last number in this list: 39750. In this case we have:$$ \begin{align} 39750 &= 2 \times 3 \times 5^3 \times 53 \\ & \rightarrow 2, 3, 5, 8 \end{align}$$If we extend the number of prime factors to five, then only one number satisfies in the range up to 40000:$$ \begin{align}34170 &= 2 \times 3 \times 5 \times 17 \times 67 \\ &\rightarrow 2, 3, 5, 8, 13 \end{align}$$However, there are 160 numbers that satisfy in the range up to one million (permalink). The algorithm actually looks for generalised Fibonacci sequences:$$a,b,c,d,e, \dots \text{ such that } c = a+b, d=b+c, e=c+d \dots$$However, all of the 160 numbers begin with 2. For example, the last of the numbers is 9988520:$$ \begin{align} 998520 &= 2^3 \times 3 \times 5 \times 53 \times 157 \\ &\rightarrow 2, 3, 5, 8, 13 \end{align} $$I tried with six prime factors but without success up to 100 million. Finally I realised that any suitable number must add to 21 and thus be divisible by 3. Such a number can never be a prime factor and so the prime factor sequence must end at 13 and can never progress further.

Sunday, 12 October 2025

A Practical Example of a Convolution

Over the past decade, for some reason, I've chosen to ignore \( \textbf{convolutions} \). Whenever they were mentioned in an OEIS sequence, I simply skipped over the reference. However, I'm now attempting to redress that neglect and to that end I was lucky to find two excellent YouTube videos about convolutions made by 3Blue1Brown (this guy has 7.76 million subscribers and for good reason). The two videos are:

One example of the use of a convolution is that of a weighted die with probabilities of a particular face showing up being given by:
  • p(1) = 0.1
  • p(2) = 0.2
  • p(3) = 0.3
  • p(4) = 0.2
  • p(5) = 0.1
  • p(6) = 0.1
If this die twice is rolled twice, what are the probabilities of throwing a 2, 3, 4, ..., 10, 11, 12? Well, the convolution of the two sequences representing the probabilities of the two dice rolls we tell you. Let's call the sequence A = [0.1, 0.2, 0.3, 0.2, 0.1, 0.1] and the classic way to facilitate the convolution is the so-called "slide and roll". We'll flip A so that it becomes B = [0.1, 0.1, 0.2, 0.3, 0.2, 0.1] and slide B progressively over A. Figure 1 shows the situation for the initial moves.


Figure 1

Of course it would be tedious to have to construct this every time we needed to evaluate a convolution and so Python makes it easier by use of the following code (input in blue, output in red):

A=[0.1,0.2, 0.3, 0.2,0.1,0.1]
result=convolution(A,A)
L=[]
for n in result:
    L.append(numerical_approx(n,digits=2))
print(L)

[0.010, 0.040, 0.10, 0.16, 0.19, 0.18, 0.14, 0.10, 0.050, 0.020, 0.010] 

Reading the output we can see that the probabilities of the various sums are as follows:
  • p(2) = 0.01
  • p(3) = 0.04
  • p(4) = 0.10
  • p(5) = 0.16
  • p(6) = 0.19
  • p(7) = 0.18
  • p(8) = 0,14
  • p(9) = 0.10
  • p(10) = 0.05
  • p(11) = 0.02
  • p(12) = 0.01
Figure 2 shows another view of what's going on. In this case, the various sum are calculated by adding up along the marked diagonals:


Figure 2

This post is simply the first in what I hope will be a series of posts relating to convolutions. As I've already discovered, convolutions linked to Fourier transforms and Laplace transformations so it's a big topic to investigate but at least I've finally made a start.