Friday, 27 June 2025

SageMath: Number Theory and Algorithms

I used Google's NotebookLM to upload all my SageMath documents. Here was the summary it provided of the 27 sources that I provided:

These SageMath excerpts explore various mathematical concepts and algorithms. They present definitions and computational methods for topics such as balanced primes, factorial and p-adic number bases, and Bell numbers. The texts also investigate number theory problems, including palindrome properties, divisibility rules, and prime number sequences like those found in OEIS (Online Encyclopedia of Integer Sequences). Furthermore, the sources cover graph theory applications with dictionaries, geometric concepts like Dyck paths, and calculations involving mathematical constants like Pi and the Golden Ratio. Finally, they illustrate probabilistic simulations and the use of plotting functions within the SageMath environment.

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

I then asked the following question:

Can you summarise what the sources have to say about matters relating prime numbers?

Here was the response:

The sources provide a comprehensive overview of various aspects related to prime numbers, their definitions, properties, classifications, and applications within SageMath.

Here's a summary of what the sources say about matters relating to prime numbers:

Basic Definitions and Concepts
  • A prime number is frequently identified using the is_prime() function in SageMath, which returns True if a number is prime and False otherwise.
  • The distinct prime factors of a number n are given by prime_factors(n) or prime_divisors(n).
  • The total number of prime factors counted with multiplicity is referred to as bigomega(n) or Ω(n), which can be found using sloane.A001222 or by summing the exponents from list(factor(n)).
  • The number of different prime divisors of n is called omega(n) or ω(n), available through sloane.A001221 or len(prime_divisors(n)).
  • To see all prime factors with their powers, the factor() command is used, which returns a factored form or a list of (base, index) pairs.
Types of Prime Numbers

The sources define and provide algorithms for various special types of prime numbers:

  • Balanced Primes: A prime number is balanced if it is the average of an equal number of primes above and below it. An algorithm generates balanced primes of a given order within a range.
  • Cuban Primes: Primes that are the difference of two consecutive cubes.
  • Emirps: A prime number that remains prime when its digits are reversed (e.g., 17 and 71). This concept can be generalized to n-almost primes.
  • Luhn Primes: Primes where the sum of the prime and its reverse (or their powers) is also a prime. Orders 1, 2, and 4 are mentioned, with algorithms provided for any order, though results are assured only for orders 1, 2, and 4.
  • Quintan Primes: Primes of the form (x^5 - y^5) / (x - y).
  • Twin Primes: A pair of primes that differ by 2 (e.g., (26111, 26113)). An algorithm lists them in a given range. The twin prime constant is also listed.
  • Truncatable Primes:
    • Left Truncatable Primes: Generated by successively removing digits from the left (e.g., 5372126317, where 12 needs to be added to the front for the next prime). Algorithms are provided for sequences starting from 3 or 7.
    • Right Truncatable Primes: Generated by successively removing digits from the right (e.g., 31193 -> 3119 -> 311 -> 31 -> 3). Algorithms are provided for sequences starting from 3 or 5.
  • Carmichael Numbers: Composite numbers that satisfy k^(n-1) ≡ 1 (mod n) for all k coprime to n. They are a special case of n-Knödel numbers where the subscript is 1. The smallest Carmichael number is 561.
  • Pseudoprimes:
    • Fermat Pseudoprimes: Composite numbers x that pass the Fermat primality test for a given base b, meaning b^(x-1) % x == 0 (where b is coprime to x).
    • Strong Fermat Pseudoprimes: Composite numbers that pass an additional, stronger primality test.
    • Euler Pseudoprimes: Odd composite integers n that satisfy a^((n-1)/2) ≡ ±1 (mod n) for a coprime to n. Every Euler pseudoprime is also a Fermat pseudoprime. Absolute Euler pseudoprimes are Euler pseudoprimes to every base coprime to themselves, and they are a subset of Carmichael numbers. The smallest absolute Euler pseudoprime is 1729.
  • Almost Primes: Numbers with a specific total count of prime factors (counted with multiplicity).
  • Semiprimes: Numbers that are the product of two primes. Algorithms are provided to generate them and apply them in other contexts, such as finding primes that are the sum of two and three successive semiprimes. A special type is Golden Semiprimes, where the factors p and q satisfy abs(p * phi - q) < 1 (where phi is the golden ratio). This can be generalized to other ratios like HDTV.
  • Sphenic Numbers: Products of three distinct primes. They can occur in pairs and triples, but not more than three consecutive ones. Algorithms generate them and calculate associated properties like surface area and ratio if viewed as rectangular prisms.
  • Ulam Numbers: Defined recursively: U1=1, U2=2. For k>2, Uk is the smallest integer that can be written in exactly one way as Ui + Uj with i < j < k. A list of the first 10,000 Ulam numbers is available, and code demonstrates their unique sum property.
  • Untouchable Numbers: Numbers that cannot be expressed as the sum of the divisors of any other number. Erdős proved there are infinitely many. An algorithm helps identify them by excluding numbers that are one or three more than a prime.
  • Euclid Numbers: Integers of the form Pn# + 1, where Pn# is the nth primorial (product of the first n prime numbers).
  • Moran Numbers: A composite number that, when divided by the sum of its digits, results in a prime number.
  • Hoax Numbers: Composite numbers where the sum of their digits equals the sum of the digits of their distinct prime factors. They are a subset of Smith numbers.
  • Smith Numbers: Composite numbers where the sum of their digits equals the sum of the digits of their prime factors (counted with multiplicity).
  • Home Prime: For a number n, its home prime is the prime reached by repeatedly concatenating its prime factors (smallest to largest) until a prime is found. Algorithms determine the home prime and the number of steps required.
  • De Polignac Numbers: Odd numbers that cannot be expressed as 2^k + p for a prime p.
  • Interprime Numbers: Numbers midway between two prime numbers.
  • n-Knödel Numbers: Composite numbers n such that for every k coprime to n, k^(n-subscript) ≡ 1 (mod n). Carmichael numbers are a special case where the subscript is 1.
  • Duffinian Numbers: Numbers that have no factors in common with their sum of divisors.
  • Zumkeller Numbers and Half-Zumkeller Numbers: Numbers whose divisors can be partitioned into two disjoint sets with equal sums.
Prime-Related Algorithms and Applications in SageMath
  • Generating Primes: prime_range(start, end) generates primes within a specified range.
  • Prime Indexing: prime_pi(n) gives the count of primes less than or equal to n (with 2 being the 1st prime). Primes().unrank(k) gives the k-th prime (with 2 being the 0th prime), while nth_prime(k) gives the k-th prime (with 2 being the 1st prime).
  • Consecutive Primes: next_prime(p) and previous_prime(p) find adjacent primes.
  • Prime Gaps: Algorithms determine and track record prime gaps (the difference between consecutive primes).
  • Density of Primes: An algorithm investigates the density of primes based on the number of digits, showing an approximately constant product of percentage of primes and number of digits.
  • Goldbach Conjecture/Decomposition/Partition: Goldbach's conjecture states every even number greater than 2 is a sum of two primes. Algorithms find the number of decompositions and the minimal decomposition. The conjecture is also extended to lucky numbers.
  • Euler Project Problem 50: An algorithm is provided to find the prime below one million that can be written as the sum of the most consecutive primes (which is 997651, sum of 543 consecutive primes).
  • Primorials: The product of the first n primes can be generated and used as a mixed radix number base.
  • Sum of Prime Factors with Multiplicity: This operation can be iterated until a 4 or a prime number is reached, with some numbers requiring many steps.
  • Numbers as Sums of Cubes of Distinct Primes: An algorithm identifies primes that are the sum of cubes of three distinct prime numbers.
  • Connections to Pi: Algorithms are provided to find primes by merging successive digits from the decimal expansion of Pi or Pi squared.
  • Ruth-Aaron Pairs & eRAPs: Algorithms identify pairs of consecutive integers that share the same sum of prime factors (either distinct or counted with multiplicity). An extension, eRAPs, considers consecutive numbers where the sums of their prime factors (with multiplicity) are consecutive.
  • Prime Attractors: In the "Odds and Evens" recursive process (adding sum of odd digits, subtracting sum of even digits), some numbers lead to attractors, and algorithms can identify prime attractors.
  • Dates and Primes: An algorithm checks if a person's age in days on their birthday is a prime number. Another algorithm identifies dates that correspond to prime numbers in a given year.
  • Palindromes and Primes: Algorithms identify composite palindromes whose sum of prime factors (with multiplicity) is also palindromic, and to list prime palindromes within a range.
  • Sum of Cubes and Primes: An algorithm identifies twin primes that are both expressible as the sum of three cubes.
  • Divisors and Coprimality: The gcd() function is used for various calculations, including identifying unitary divisors and Carmichael numbers. n.coprime_integers(m) returns integers less than m that are coprime to n.
  • Modular Arithmetic: The IntegerModRing() function allows for computations in modular arithmetic, essential for primality tests and properties of numbers modulo n.
  • Multipurpose Algorithm: A single algorithm can perform multiple number theory checks on a given number, including primality tests, factorisation, sum of divisors, pseudoperfectness, Zumkeller status, practicality, Duffinian nature, cyclicity, d-powerful property, sum of squares/cubes of digits, and de Polignac property.
OEIS Sequences Related to Primes

Many algorithms are designed to generate terms for specific OEIS (Online Encyclopedia of Integer Sequences) sequences related to primes and prime-derived numbers:

  • A002858: Ulam numbers.
  • A048168: n is divisible by the square of the number of unitary divisors of n.
  • A064599: Sum of non-unitary divisors of n divides n.
  • A129485: Odd unitary abundant numbers.
  • A005114: Untouchable numbers.
  • A048128: Numbers becoming prime or 4 after exactly 6 iterations of f(x) = sum of prime factors of x.
  • A002407: Cuban primes.
  • A137365: Prime numbers n such that n = p1^3 + p2^3 + p3^3, a sum of cubes of 3 distinct primes.
  • A138938: Indices k such that cyclotomic_polynomial(k, 8) is prime.
  • A003635: Inconsummate numbers.
  • A046411: Composite numbers where the concatenation of their prime factors is a prime (single step to home prime).
  • A108540: Golden semiprimes.
  • A255897: Primes equal to the sum of both two and three successive semiprimes.
  • A006558: Start of the first run of n consecutive integers with the same number of divisors.
  • A045983: Numbers k such that n or more consecutive integers starting at k have the same number of distinct prime divisors.
  • A046354: Composite palindromes whose sum of prime factors (with multiplicity) is palindromic.
  • A056215: Primes p for which the period of reciprocal 1/p equals (p-1)/10.
  • A104825 / A104928: Primes from merging successive digits in the decimal expansion of Pi or Pi squared.
  • A048131: Numbers becoming prime or 4 after exactly 9 iterations of f(x) = sum of prime factors of x.
  • A006038: Odd primitive abundant numbers.
  • A005835: Pseudoperfect numbers.
  • A262054: Euler pseudoprimes to base 7.
  • A002649: Quintan primes.
  • A085158 / A289697: Sextuple factorial and numbers k such that k!6 - 24 is prime.
  • A131354: Number of primes in the open interval between successive tribonacci numbers.
  • A053584: Smallest prime ending with a(n), where a(1)=7 (related to left truncatable primes).
  • A000005: The tau function (number of divisors).
  • A270865: Smallest primes of 4x4 semi-magic squares formed from consecutive primes.
  • A038369: Sum-product numbers.

The sources provide algorithms, definitions, and examples, often linking to OEIS for further information. They also highlight the computational challenges of generating very large numbers or sequences in SageMathCell due to timeouts.

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

The NotebookLM provides links to all the items referenced which is quite useful. These are lost in the copy-paste to Blogger. Gemini admits this limitation and it's just another example of Google's lack of support for this blogging platform. Here is the link to the SageMath: Number Theory and Algorithms NotebookLM.

Monday, 23 June 2025

Lottery Numbers

 


Figure 1

Figure 1 shows the Lotto results for Saturday night 21st June 2025. What's unusual about the numbers is that seven out of the eight numbers are even. I was wondering as to the probability of this happening. To begin with there are 45 numbers to choose from: 22 are even and 23 are odd. See Figure 2.


Figure 2

Looking at the draw we see that the first number drawn was a 6 and this is an even number. The probability of drawing an even number is 22/45. The next three numbers were all even as well and the probabilities are therefore 21/44, 20/43 and 19/42. Then comes the only odd number, 1, and the probability of drawing an odd number is 23/41. The final three numbers are all even with probabilities of 18/40, 17/39 and 16/38. So the probability of this configuration:$$ \text{even, even, even, even. odd, even, even, even}$$is given by:$$\frac{22}{45} \times \frac{21}{44} \times \frac{20}{43} \times \frac{19}{42} \times \frac{23}{41} \times \frac{18}{40} \times \frac{17}{39} \times \frac{16}{38} \approx 0.0023$$However, we're not concerned with that particular order of even and odd numbers. We only want to determine the probability of seven even numbers and one odd number. The odd number could be in the first to eighth position. Each of these eight configurations has the same probability, around 0.0023, so we need to multiply by eight. This gives 0.01820 to five decimal places or a probability of around 1.82% and so$$\text{probability of one odd and seven even numbers } \approx 1.82 \text{%} $$Another way to approach the probability is via combinations. Let's see if we get the same result using this approach. There are \(^{22} \text{C}_{7}\) ways of choosing seven even numbers from the 22 available and \( ^23 \text{C}_1\) ways of choosing an odd number. With no restrictions, there are \( ^45 \text{C}_8 \) ways of choosing eight numbers from the 45 available. Thus:$$ \begin{align} \text{probability } &= \frac{^{22} \text{C}_{7} \times ^{23} \text{C}_1}{^{45} \text{C}_8}\\  \\[-1.5 ex] &=\frac{170544 \times 23}{215553195} \\[-0.5 ex]  \\ &\approx 0.01820 \\[-1.5 ex]  \\ &\approx 1.82\text{%} \end{align} $$So there is agreement. The probability that all the numbers are even would be given by:$$ \begin{align} \text{probability all even } &= \frac{ ^{22} \text{C}_8}{ ^{45} \text{C}_8}\\ \\[-1.5 ex] &\approx 0.00148 \\[-1.5 ex] \\ &\approx 0.148 \text{%} \end{align}$$This is considerably more unlikely than getting seven out of eight!

Sunday, 22 June 2025

Sum of Divisors Meets the Totient

The number associated with my diurnal age today, \(\textbf{27838}\), has an interesting property that is not so obvious until we look at its sum of divisors and it totient:$$ \begin{align}  \sigma(27838) &= 43200 \\ &= 2^6 \times 3^3 \times 5^2 \\ &\rightarrow 2,3,5 \text{ as distinct prime factors}\\ \phi(27838) &= 13440 \\&= 2^7 \times 3 \times 5 \times 7 \\ &\rightarrow 2,3,5,7 \text{ as distinct prime factors} \end{align}$$For both the sum of divisors and the totient, the prime factors are consecutive. This got me thinking as to how many numbers enjoy this property in the range up to 40000. I wasn't requiring that the smallest factor be 2 for both the sum of divisors and the totient but this is certainly the case at least in the range under consideration. 

In developing my algorithm (permalink), I naturally only considered composite numbers but I also required the sum of divisors and the totient to be composite as well. It turns out that there are 785 such numbers with the smallest being 14:$$ \begin{align}  \sigma(14) &= 24 \\ &= 2^3 \times 3 \\ &\rightarrow 2,3 \text{ as distinct prime factors}\\ \phi(14) &= 6 \\&= 2 \times 3  \\ &\rightarrow 2,3 \text{ as distinct prime factors} \end{align}$$Table 1 shows the numbers between 27838 and 30000.


Table 1: permalink

Here is the full list of the 146 numbers between 27838 and 40000 (permalink):

27838, 27956, 28126, 28215, 28258, 28329, 28340, 28424, 28458, 28614, 28728, 28768, 28782, 28809, 28826, 28985, 29029, 29222, 29260, 29295, 29337, 29393, 29512, 29640, 29667, 29678, 29835, 29848, 30039, 30184, 30240, 30264, 30305, 30381, 30504, 30566, 30760, 30780, 30814, 30888, 30914, 30943, 30956, 30996, 31008, 31027, 31160, 31174, 31283, 31331, 31392, 31416, 31465, 31496, 31529, 31806, 31816, 32103, 32130, 32131, 32298, 32376, 32395, 32589, 32604, 32718, 32802, 32984, 33015, 33176, 33292, 33345, 33383, 33440, 33480, 33495, 33497, 33528, 33572, 33592, 33836, 33885, 33915, 34008, 34162, 34276, 34293, 34317, 34440, 34452, 34573, 34580, 34605, 34782, 34884, 35061, 35074, 35112, 35340, 35343, 35424, 35464, 35530, 35752, 35805, 35910, 35948, 35960, 36366, 36423, 36666, 36828, 36859, 36860, 36890, 36920, 37060, 37128, 37417, 37638, 37719, 37730, 37758, 37772, 37961, 38038, 38152, 38285, 38340, 38368, 38408, 38610, 38745, 38760, 38874, 39032, 39121, 39219, 39270, 39370, 39458, 39501, 39520, 39556, 39576, 39729

If we consider the sum of the \( \textbf{proper} \) divisors of a number together with the totient, we find that only 104 numbers qualify in the range from 1 up to 40000. These are (permalink):

42, 78, 90, 93, 135, 198, 216, 219, 259, 270, 273, 360, 364, 403, 438, 679, 723, 738, 793, 988, 1080, 1299, 1333, 1446, 1683, 1722, 1793, 1818, 1924, 2009, 2044, 2263, 2295, 2623, 2743, 2754, 2970, 3135, 3157, 3162, 3258, 3420, 3589, 3796, 3960, 4284, 4320, 4440, 4453, 4564, 4905, 5187, 5824, 5983, 5995, 6893, 6918, 7320, 7373, 7380, 7392, 7783, 7980, 8928, 8987, 9504, 9720, 9943, 10864, 10920, 11023, 11538, 11653, 11904, 14233, 15613, 15813, 16764, 17593, 18019, 20202, 22625, 24199, 24339, 24613, 25275, 25324, 25792, 27133, 28243, 28564, 30240, 30303, 30623, 31408, 31992, 32283, 32284, 34300, 34393, 34933, 36421, 36720, 39283

Not all the prime factors of the sum of proper divisors begin with 2 as can be seen in Table 2 that shows the details for numbers between 28000 and 40000:


Table 2: permalink

Monday, 16 June 2025

A Special 29x + 1 Map

 In blog posts titled:

I've looked at Collatz-style sequences of the form \(px+1\) that map a number \(n\) to the following:
  • \(n \rightarrow \dfrac{n}{2}\) if \(2 \, | \, n\)
  • \(n \rightarrow \dfrac{n}{3}\) if \(3 \, | \, n\)
  • \(n \rightarrow \dfrac{n}{5}\) if \(5 \, | \, n\)
     \(\dots\)
  • \(n \rightarrow \dfrac{n}{p-1}\) if \((p-1) \, | \, n\)
  • \(n \rightarrow p \times n+1\) \( \text{ if none of the primes less than }p \text{ divide } n\)
Other mappings are of course possible and the following is perhaps the simplest of all. For a given prime \(p\) when applied to a number \(n\), the rule is:
  • \(n \rightarrow \dfrac{n}{2}\) if \(n\) is even
  • \(n \rightarrow p \times n + 1\) if \(n\) is odd
For \(p=3\), this is the Collatz trajectory of the number. Let's apply this sort of modified \(px+1\) mapping in the case of \(n=3\). The sequence formed by the trajectory up to one million is then (permalink):

3, 88, 44, 22, 11, 320, 160, 80, 40, 20, 10, 5, 146, 73, 2118, 1059, 30712, 15356, 7678, 3839, 111332, 55666, 27833, 807158, 403579, 11703792, 5851896, 2925948, 1462974, 731487 (OEIS A037112)

The trajectory is shown in Figure 1 using a logarithmic scale for the \(y\) axis:


Figure 1: permalink

By contrast if the first mentioned rule above were applied then the trajectory would be short-lived indeed:$$3 \rightarrow  1 \rightarrow  30 \rightarrow  15 \rightarrow 5 \rightarrow  1$$It can be seen that the trajectory very quickly enters a loop. 

Letting \(p=101\) and applying the mapping to \(n=3\) once again, we get the following sequence up to one million formed by the trajectory (permalink):

3, 304, 152, 76, 38, 19, 1920, 960, 480, 240, 120, 60, 30, 15, 1516, 758, 379, 38280, 19140, 9570, 4785, 483286, 241643

The trajectory is shown in Figure 2 using a logarithmic scale for the \(y\) axis:

Figure 2: permalink

Thursday, 12 June 2025

Fibonacci Numbers Derived From Single Digits

Quite some time ago now I used "reverse engineering" to find the seed numbers leading to a given number. For example, take the number 28047. Using this algorithm (permalink), I obtain the following output.

Seed numbers for Fibonacci sequence are 3 and 9

[3, 9, 12, 21, 33, 54, 87, 141, 228, 369, 597, 966, 1563, 2529, 4092, 6621, 10713, 17334, 28047]

I outlined the construction of this algorithm in a post titled Finding Fibonacci and Tribonacci Seed Numbers in July of 2019. The previously applied algorithm relies on the fact that in a Fibonacci sequence the ratio of progressive terms approximates the golden ratio. Let's apply the algorithm once again but this time to the number 28048. The following output is obtained:

Seed numbers for Fibonacci sequence are 32 and 175

[32, 175, 207, 382, 589, 971, 1560, 2531, 4091, 6622, 10713, 17335, 28048]

The difference this time is that the seed numbers are no longer single digits and this is generally the case. What I wanted to know was what numbers in the range up to 40000 can be formed using single digits as seed numbers after applying the Fibonacci algorithm to generate the subsequent numbers. It turns out that there are only 387 such numbers in the range from 10 to 40000. They are (permalink):

10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 60, 61, 63, 64, 65, 66, 68, 69, 71, 72, 73, 74, 76, 77, 78, 79, 81, 82, 84, 86, 87, 89, 91, 92, 94, 97, 99, 102, 104, 105, 107, 110, 112, 115, 117, 118, 120, 123, 125, 126, 128, 131, 133, 136, 139, 141, 144, 147, 149, 152, 157, 160, 165, 168, 170, 173, 178, 181, 186, 189, 191, 194, 199, 202, 204, 207, 212, 215, 220, 225, 228, 233, 238, 241, 246, 254, 259, 267, 272, 275, 280, 288, 293, 301, 306, 309, 314, 322, 327, 330, 335, 343, 348, 356, 364, 369, 377, 385, 390, 398, 411, 419, 432, 440, 445, 453, 466, 474, 487, 495, 500, 508, 521, 529, 534, 542, 555, 563, 576, 589, 597, 610, 623, 631, 644, 665, 678, 699, 712, 720, 733, 754, 767, 788, 801, 809, 822, 843, 856, 864, 877, 898, 911, 932, 953, 966, 987, 1008, 1021, 1042, 1076, 1097, 1131, 1152, 1165, 1186, 1220, 1241, 1275, 1296, 1309, 1330, 1364, 1385, 1398, 1419, 1453, 1474, 1508, 1542, 1563, 1597, 1631, 1652, 1686, 1741, 1775, 1830, 1864, 1885, 1919, 1974, 2008, 2063, 2097, 2118, 2152, 2207, 2241, 2262, 2296, 2351, 2385, 2440, 2495, 2529, 2584, 2639, 2673, 2728, 2817, 2872, 2961, 3016, 3050, 3105, 3194, 3249, 3338, 3393, 3427, 3482, 3571, 3626, 3660, 3715, 3804, 3859, 3948, 4037, 4092, 4181, 4270, 4325, 4414, 4558, 4647, 4791, 4880, 4935, 5024, 5168, 5257, 5401, 5490, 5545, 5634, 5778, 5867, 5922, 6011, 6155, 6244, 6388, 6532, 6621, 6765, 6909, 6998, 7142, 7375, 7519, 7752, 7896, 7985, 8129, 8362, 8506, 8739, 8883, 8972, 9116, 9349, 9493, 9582, 9726, 9959, 10103, 10336, 10569, 10713, 10946, 11179, 11323, 11556, 11933, 12166, 12543, 12776, 12920, 13153, 13530, 13763, 14140, 14373, 14517, 14750, 15127, 15360, 15504, 15737, 16114, 16347, 16724, 17101, 17334, 17711, 18088, 18321, 18698, 19308, 19685, 20295, 20672, 20905, 21282, 21892, 22269, 22879, 23256, 23489, 23866, 24476, 24853, 25086, 25463, 26073, 26450, 27060, 27670, 28047, 28657, 29267, 29644, 30254, 31241, 31851, 32838, 33448, 33825, 34435, 35422, 36032, 37019, 37629, 38006, 38616, 39603

The algorithm can also be used to enter any of the above numbers to find the seed numbers and the resulting sequence. For example, entering the last number in the above sequence (39603) reveals that it can formed by three different pairs of seed numbers: (1, 3), (3, 4) and (4, 7). The resulting sequences are essentially the same from 11 onwards:

1, 3, 4, 7, 11, 18, 29, 47, 76, 123, 199, 322, 521, 843, 1364, 2207, 3571, 5778, 9349, 15127, 24476, 39603

3, 4, 7, 11, 18, 29, 47, 76, 123, 199, 322, 521, 843, 1364, 2207, 3571, 5778, 9349, 15127, 24476, 39603

4, 7, 11, 18, 29, 47, 76, 123, 199, 322, 521, 843, 1364, 2207, 3571, 5778, 9349, 15127, 24476, 39603

Between 10 and 100, the numbers that CANNOT be derived from single digit seed numbers are 59, 62, 67, 70, 75, 80, 83, 85, 88, 90, 93, 95, 96, 98 and 100. The frequency of these numbers increases rapidly as the numbers get larger. For example, between 38616 and 39603 there is a gap of 87 and so there are 85 such numbers in the range.

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, 7 June 2025

Dangers of Differentiation

The following shows an interesting line of reasoning posed by Math Lazy Hazel on Twitter.



What is faulty in this demonstration that 2 = 1? I asked Gemini via this prompt:
There is a flaw in the logic of the Mathematics on this uploaded file. Can you ascertain what it is? On the surface the differentiation seems logical enough.

The response was quite well explained.

Of course. The flaw in the mathematical logic lies in the incorrect application of differentiation to a sum with a variable number of terms. Here’s a breakdown of the error: 
\( \textbf{The Flaw Explained}\) 
The core mistake happens when moving from the second to the third line of the "proof." 
\( \textbf{The Setup}\): 
The proof starts by defining \(x^2\) as the sum of \(x\) added to itself \(x\) times: $$x^2 = \underbrace{x + x + \dots + x}_{x \text{ times}}$$ This definition itself is only truly valid for integer values of \(x\). 2.

\( \textbf{The Incorrect Differentiation}\): 
The next step applies the derivative with respect to \(x\) to both sides: $$\frac{d}{dx}x^2 = \frac{d}{dx}\left(\underbrace{x + x + \dots + x}_{x \text{ times}}\right)$$ The left side correctly becomes \(2x\). However, the right side is differentiated incorrectly. The proof mistakenly treats the number of terms in the sum as a constant. The rule for the derivative of a sum, \(\frac{d}{dx}\sum f_i = \sum \frac{d}{dx}f_i\), only works when the number of terms is constant. In this case, the number of terms is \(x\), the very variable you are differentiating with respect to. You cannot simply differentiate each term individually and add them up while ignoring that the number of terms is also changing.

\( \textbf{Correct Approach}\)
To correctly differentiate the expression on the right, you must use the product rule, because it's effectively a product of two functions of \(x\): the value of each term (\(x\)) and the number of terms (\(x\)). Let the function be \(f(x) = x \cdot x\). Using the product rule \((uv)' = u'v + uv'\): $$ \begin{align*} \frac{d}{dx}(x \cdot x) &= \left(\frac{d}{dx}x\right) \cdot x + x \cdot \left(\frac{d}{dx}x\right) \\ &= (1 \cdot x) + (x \cdot 1) \\ &= x + x = 2x \end{align*} $$ This correct differentiation results in \(2x = 2x\), which is a valid identity and does not lead to the false conclusion that \(2=1\). In short, the proof is flawed because it misapplies the rules of differentiation by treating a variable number of terms as a constant.