Showing posts with label OEIS. Show all posts
Showing posts with label OEIS. Show all posts

Wednesday, 3 December 2025

28003: A Lesson Learned

One of the limitations of the free version of the Airtable online database is that it only allows about 1000 records per database. Once the limit is reached, you need to create a new database to accommodate your needs. I've been using Airtable for years now and I am into my third database:

This is an impressive combined database containing about 3000 records. However, the records are in three disconnected databases and once I move on to a new database, I've tended to ignore the earlier databases. However, I realised the folly of doing this when confronted with something interesting to say about the number associated with my diurnal age today: \( \textbf{28003}\).


It's not dark yet but it's getting there

The OEIS, Mathematical Meanderings (my Mathematics blog), Bespoken for Sequences and Diurnal Age Part 3 (in short all my usual sources) had nothing useful to contribute. It then occurred to me to look back at my Diurnal Age Part 2 database and I was pleasantly surprised at what I found therein. Let's begin:

  • \( \textbf{28003} \) is a member of OEIS A179248: numbers that have 8 terms in their Zeckendorf representation: [3, 8, 89, 233, 610, 2584, 6765, 17711]. There is in face a cluster of sequence members nearby, namely 27800, 27802, 27804, 27807, 27808, 27809 and 27811.

  • \( \textbf{28003}\) is a member of OEIS A157344: semiprimes that are the product of two distinct Sophie Germain primes. Approximately 2.52% of numbers in the range up to 40,000 satisfy this criterion. Here the primes are 41 and 683 and we have:
    • 41 x 2 + 1 = 83 which is prime
    • 683 x 2 + 1 = 1367 which is prime

  • \( \textbf{28003}\) is a member of OEIS A082957: numbers \(n\) such that \( \sigma(2n) < \sigma(2n+1) \). These numbers total 5.52% in the range up to 40,000. There are 2301 primes and 3169 composites among the 5470 first terms. Here we have:
    • \( \sigma(2 \times 28003) = \sigma(56006) = 86184\)
    • \( \sigma(2 \times 28003 + 1) = \sigma(56007) = 94848\)

  • \( \textbf{28003} \) is a member of OEIS A134252: positions of 2 after decimal point in decimal expansion of \( \frac{1}{\pi}\). 

Diurnal Age Part 1 yielded no results but as can be seen Diurnal Age Part 2 revealed membership of \( \textbf{28003}\) in four different OEIS sequences.

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.

Monday, 9 June 2025

Nothing New Under The Sun

Every day I try to form a digit equation from the digits of the number associated with my diurnal age. Today's number was \( \textbf{27826} \). Usually I succeed but sometimes I don't. I've described the rules in my blog post titled Forming Digit Equations: A Game. Applying these rules to 27826 we get (with | representing divided into):$$ \begin{align} -2 + 7 &= 8 - 2 \, | \, 6 \\ 5 &= 8 -3 \\&=5 \end{align}$$Looking at this number however, something else caught my eye and it involved powers of 2. I thought: suppose that instead of 27 there was \(2^7 = 128 \) and instead of 26 there was \(2^6=64\). In that case the number would be 128864. Now we have a number that is a concatenation of powers of 2 because (with | this time representing concatenation) we have:$$128864 = 2^7 \, | \, 2^3 \, | \, 2^6$$I wondered how many numbers in the range up to 40000 have the property that they are a concatenation of powers of 2, which includes \(2^0=1\). As is my lazy way nowadays I put Gemini to work writing the Python code (permalink) to find all the numbers in this range. It turns out that there are 1563 such numbers with the largest being 32888 where:$$32888 = 2^5 \, | \, 2^3 \, | \, 2^3 \, | \, 2^3$$The initial numbers are 1, 2, 4, 8, 11, 12, 14, 16, 18, 21 and so I thought I'd put these numbers into the OEIS and see if anything turned up. To my surprise, the sequence is listed (A381259). See Figure 1.

Figure 1: link

Hence the title of this post "Nothing New Under the Sun" because clearly someone had thought of such a sequence before I had. I won't list all the numbers in the range up to 40000 but here are the ones that are coming up for me:

28111, 28112, 28114, 28116, 28118, 28121, 28122, 28124, 28128, 28132, 28141, 28142, 28144, 28148, 28161, 28162, 28164, 28168, 28181, 28182, 28184, 28188, 28192, 28211, 28212, 28214, 28216, 28218, 28221, 28222, 28224, 28228, 28232, 28241, 28242, 28244, 28248, 28256, 28264, 28281, 28282, 28284, 28288, 28321, 28322, 28324, 28328, 28411, 28412, 28414, 28416, 28418, 28421, 28422, 28424, 28428, 28432, 28441, 28442, 28444, 28448, 28464, 28481, 28482, 28484, 28488, 28512, 28641, 28642, 28644, 28648, 28811, 28812, 28814, 28816, 28818, 28821, 28822, 28824, 28828, 28832, 28841, 28842, 28844, 28848, 28864, 28881, 28882, 28884, 28888, 32111, 32112, 32114, 32116, 32118, 32121, 32122, 32124, 32128, 32132, 32141, 32142, 32144, 32148, 32161, 32162, 32164, 32168, 32181, 32182, 32184, 32188, 32211, 32212, 32214, 32216, 32218, 32221, 32222, 32224, 32228, 32232, 32241, 32242, 32244, 32248, 32256, 32264, 32281, 32282, 32284, 32288, 32321, 32322, 32324, 32328, 32411, 32412, 32414, 32416, 32418, 32421, 32422, 32424, 32428, 32432, 32441, 32442, 32444, 32448, 32464, 32481, 32482, 32484, 32488, 32512, 32641, 32642, 32644, 32648, 32768, 32811, 32812, 32814, 32816, 32818, 32821, 32822, 32824, 32828, 32832, 32841, 32842, 32844, 32848, 32864, 32881, 32882, 32884, 32888

I looked long and hard at 32768 in the list above because I couldn't see how it could be a concatenation of powers of 2. I had to ask Gemini to clarify. It did:$$32768=2^{15}$$So there you have it. I thought I'd discovered a brand new sequence but it was already in the OEIS database but it hadn't been there for long as the date of inclusion is February 18th 2025.

Now the Python code is easily modified to deal with the powers of other numbers. Let's consider powers of 3. There are 570 numbers satisfying this criterion in the range up to 40000 (permalink). Here are the ones that are coming up for me (some of which I'll see hopefully):

27911, 27913, 27919, 27927, 27931, 27933, 27939, 27981, 27991, 27993, 27999, 31111, 31113, 31119, 31127, 31131, 31133, 31139, 31181, 31191, 31193, 31199, 31243, 31271, 31273, 31279, 31311, 31313, 31319, 31327, 31331, 31333, 31339, 31381, 31391, 31393, 31399, 31729, 31811, 31813, 31819, 31911, 31913, 31919, 31927, 31931, 31933, 31939, 31981, 31991, 31993, 31999, 32187, 32431, 32433, 32439, 32711, 32713, 32719, 32727, 32731, 32733, 32739, 32781, 32791, 32793, 32799, 33111, 33113, 33119, 33127, 33131, 33133, 33139, 33181, 33191, 33193, 33199, 33243, 33271, 33273, 33279, 33311, 33313, 33319, 33327, 33331, 33333, 33339, 33381, 33391, 33393, 33399, 33729, 33811, 33813, 33819, 33911, 33913, 33919, 33927, 33931, 33933, 33939, 33981, 33991, 33993, 33999, 36561, 37291, 37293, 37299, 38111, 38113, 38119, 38127, 38131, 38133, 38139, 38181, 38191, 38193, 38199, 39111, 39113, 39119, 39127, 39131, 39133, 39139, 39181, 39191, 39193, 39199, 39243, 39271, 39273, 39279, 39311, 39313, 39319, 39327, 39331, 39333, 39339, 39381, 39391, 39393, 39399, 39729, 39811, 39813, 39819, 39911, 39913, 39919, 39927, 39931, 39933, 39939, 39981, 39991, 39993, 39999

Let's take the first number in the list above:$$27911= 3^3 \, | \, 3^2 \, | \, 3^0 \, | \, 3^0 $$Similarly with powers of 5 where we have 103 suitable numbers in the range up to 40000 (permalink). We can list them here as there aren't that many.

1, 5, 11, 15, 25, 51, 55, 111, 115, 125, 151, 155, 251, 255, 511, 515, 525, 551, 555, 625, 1111, 1115, 1125, 1151, 1155, 1251, 1255, 1511, 1515, 1525, 1551, 1555, 1625, 2511, 2515, 2525, 2551, 2555, 3125, 5111, 5115, 5125, 5151, 5155, 5251, 5255, 5511, 5515, 5525, 5551, 5555, 5625, 6251, 6255, 11111, 11115, 11125, 11151, 11155, 11251, 11255, 11511, 11515, 11525, 11551, 11555, 11625, 12511, 12515, 12525, 12551, 12555, 13125, 15111, 15115, 15125, 15151, 15155, 15251, 15255, 15511, 15515, 15525, 15551, 15555, 15625, 16251, 16255, 25111, 25115, 25125, 25151, 25155, 25251, 25255, 25511, 25515, 25525, 25551, 25555, 25625, 31251, 31255

Let's take the last number in the list:$$31255 = 5^5 \, | \, 5^1$$Representations are not necessarily unique. For example:$$ \begin{align} 15125 &= 5^0 \, | \,  5^1 \, | \,5^3 \\ &= 5^0 \, | \, 5^1 \, | \, 5^0 \, | \,5^2 \end{align}$$Finally let's consider powers of 7 where there are 96 in the range up to 40000 (permalink). They are:

1, 7, 11, 17, 49, 71, 77, 111, 117, 149, 171, 177, 343, 491, 497, 711, 717, 749, 771, 777, 1111, 1117, 1149, 1171, 1177, 1343, 1491, 1497, 1711, 1717, 1749, 1771, 1777, 2401, 3431, 3437, 4911, 4917, 4949, 4971, 4977, 7111, 7117, 7149, 7171, 7177, 7343, 7491, 7497, 7711, 7717, 7749, 7771, 7777, 11111, 11117, 11149, 11171, 11177, 11343, 11491, 11497, 11711, 11717, 11749, 11771, 11777, 12401, 13431, 13437, 14911, 14917, 14949, 14971, 14977, 16807, 17111, 17117, 17149, 17171, 17177, 17343, 17491, 17497, 17711, 17717, 17749, 17771, 17777, 24011, 24017, 34311, 34317, 34349, 34371, 34377

Let's take the last number in the list again:$$34377=7^3 \, | \, 7^1 \, | \,  7^1$$Apart from the powers of 2, none of the sequences above are listed in the OEIS. Of course, those numbers containing only the digit 1 are common to all the sequences.

Saturday, 24 May 2025

A + B = C

In the range up to, let's say 40000, how many numbers \(c\) are there such that:$$a+b=c$$where \(a\), \(b\) and \(c\) contain the same decimal digits. I got Gemini to write some Python code in order to identify these numbers. I knew that the number associated with my diurnal age today, \( \textbf{27810} \), was one such number since it belongs to OEIS A203024. The code is shown at the end of this post.

The code outputs the following numbers up to 40000:

954, 2961, 4932, 5013, 5022, 5031, 5238, 5823, 6147, 6417, 7614, 7641, 8235, 8523, 9045, 9108, 9180, 9324, 9504, 9540, 9594, 9612, 9684, 9774, 9864, 9954, 20961, 21150, 21501, 24831, 24921, 25011, 26901, 27810, 28107, 28314, 29016, 29214, 29610, 29691, 29961, 30168, 30186, 31077, 31257, 31275, 31482, 31824, 32148, 32184, 32481, 32814, 34182, 34218, 34281, 34812, 35127, 35712, 36819, 37125, 37512, 38124, 38142, 38241, 38421, 38619

Here is a table showing the details for each number:

-----------------------------------
c (n)      | a (b)      | b (n-b)   
-----------------------------------
954        | 459        | 495       
2961       | 1269       | 1692      
4932       | 2439       | 2493      
5013       | 1503       | 3510      
5022       | 2502       | 2520      
5031       | 1530       | 3501      
5238       | 2385       | 2853      
5823       | 2538       | 3285      
6147       | 1476       | 4671      
6417       | 1746       | 4671      
7614       | 1467       | 6147      
7641       | 1467       | 6174      
8235       | 2853       | 5382      
8523       | 3285       | 5238      
9045       | 4095       | 4950      
9108       | 1089       | 8019      
9180       | 1089       | 8091      
9324       | 4392       | 4932      
9504       | 4095       | 5409      
9540       | 4590       | 4950      
9594       | 4599       | 4995      
9612       | 2691       | 6921      
9684       | 4698       | 4986      
9774       | 4797       | 4977      
9864       | 4896       | 4968      
9954       | 4959       | 4995      
20961      | 10269      | 10692     
21150      | 10125      | 11025     
21501      | 10251      | 11250     
24831      | 12348      | 12483     
24921      | 12429      | 12492     
25011      | 12501      | 12510     
26901      | 10692      | 16209     
27810      | 10728      | 17082     
28107      | 10287      | 17820     
28314      | 13482      | 14832     
29016      | 12096      | 16920     
29214      | 14292      | 14922     
29610      | 12690      | 16920     
29691      | 12699      | 16992     
29961      | 12969      | 16992     
30168      | 13860      | 16308     
30186      | 13806      | 16380     
31077      | 13707      | 17370     
31257      | 13725      | 17532     
31275      | 13752      | 17523     
31482      | 13248      | 18234     
31824      | 13482      | 18342     
32148      | 13824      | 18324     
32184      | 13842      | 18342     
32481      | 14238      | 18243     
32814      | 14382      | 18432     
34182      | 12348      | 21834     
34218      | 12384      | 21834     
34281      | 12438      | 21843     
34812      | 13428      | 21384     
35127      | 13752      | 21375     
35712      | 12537      | 23175     
36819      | 16983      | 19836     
37125      | 15372      | 21753     
37512      | 12375      | 25137     
38124      | 14283      | 23841     
38142      | 13824      | 24318     
38241      | 13428      | 24813     
38421      | 14238      | 24183     
38619      | 18936      | 19683     
-----------------------------------

Total numbers found: 66

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

def
find_permutation_sums_up_to(limit):
    """
    Finds all numbers 'n' up to a given limit that can be expressed as the sum
    of two numbers 'b' and 'n-b', where n, b, and n-b are permutations of
    each other's digits. Displays the results in a tabular format and
    a comma-separated list of 'c' numbers.
    """
    found_c_numbers = [] # To store only the 'c' values
    print(f"Searching for permutation sums up to {limit}...")
    print("-" * 35)
    print(f"{'c (n)':<10} | {'a (b)':<10} | {'b (n-b)':<10}")
    print("-" * 35)
    for n in range(1, limit + 1):
        s_n = sorted(str(n))
        min_b = int("".join(s_n))
        # Optimization: If min_b is greater than n, no permutation of n's digits
        # can be smaller than n, so no valid 'b' can be formed.
        if min_b > n:
            continue
        for b in range(max(1, min_b), n // 2 + 1):
            s_b = sorted(str(b))
            s_n_minus_b = sorted(str(n - b))
            if s_b == s_n and s_n_minus_b == s_n:
                found_c_numbers.append(n) # Add 'c' to the list
                print(f"{n:<10} | {b:<10} | {n - b:<10}")
                break  # Found a pair for 'n', move to the next 'n'
    print("-" * 35)
    print(f"\nTotal numbers found: {len(found_c_numbers)}")
    # Display the comma-separated list of 'c' numbers
    if found_c_numbers:
        print("\nComma-separated list of 'c' numbers:")
        print(", ".join(map(str, found_c_numbers)))
    else:
        print("\nNo 'c' numbers found within the specified limit.")
# Run the search up to 40000
find_permutation_sums_up_to(40000)  
 

Comments on Code:

found_c_numbers = []: A new list is introduced at the beginning of the function to store just the n (or c) values that satisfy the condition. 
 
found_c_numbers.append(n): Inside the if block where a valid triplet is found, n is appended to this new list. 
 
Printing the Comma-Separated List:
After the main for loop finishes, an if found_c_numbers: check ensures that we only try to print if there are numbers to print.
print(", ".join(map(str, found_c_numbers))):
map(str, found_c_numbers) converts each integer in the found_c_numbers list to a string.
", ".join(...) then concatenates these strings with a comma and space in between, creating the desired comma-separated list.
An else block is added to inform the user if no numbers were found. 
 
Minor Optimization:
Added if min_b > n: continue inside the main loop. This is a small optimization. If the smallest number that can be formed from n's digits is greater than n itself, then b (which must be a permutation of n's digits) can't be n or smaller, making it impossible for b and n-b to also be permutations of n. This happens for numbers like 10 where min_b would be 1. While b does not necessarily have to be exactly a permutation of n, this check ensures that b is at least within the range of numbers that n's digits can form. This is particularly relevant when n starts with zeros, e.g., for n=01 (which is 1), min_b would be 1. However, str(n) correctly handles this by giving "1", so min_b would correctly be 1. This optimization is generally more critical in other permutation problems, but it doesn't hurt here.