Sunday, 11 October 2020

Nude Numbers

It was only in my previous post that I mentioned Friedman numbers, named after the former Associate Professor of Mathematics at Stetson University in DeLand, Florida. His name popped up again this morning when I was investigating the number associated with my diurnal age: 26124. Before discussing the mathematical property of this number, namely its "nudity", I'll include some biographical information about Erich Friedman that I found on his website:

My name is Erich Friedman. For 26 years, I was a Professor of Mathematics at Stetson University, located in DeLand, Florida. I retired in 2018 to spend more time on my other interests, including recreational mathematics, puzzles, trivia, and my girlfriend of 30 years. I was born in 1965 in West Lafayette, Indiana. I grew up in Indianapolis and went to North Central High School. I got my bachelor's degree from Rose-Hulman in 1987, and my Ph.D. from Cornell University in 1991, and have been at Stetson ever since.

There's more information on his website but that's enough for this post. Suffice to say that his website looks interesting with many links to mathematical topics. Eric Friedman is the author of OEIS A034838: numbers \(n\) that are divisible by every digit of \(n\). 26214 is a member of this sequence because 1, 2, 4 and 6 do indeed divide into it without remainder.

I was lead to this sequence by a link in Numbers Aplenty concerning what are colorfully called nude numbers, so called because such numbers expose some of their factors. The explanation on the Numbers Aplenty website runs like this:

Y.Katagiri calls a number nude if it is divisible by all of its digits (which should be nonzero) like \(672=6\cdot112=7\cdot96=2\cdot 336\). The number is called "nude" because it exposes some of its factors. There are only \(9039\) such numbers below one million, however there are infinite nude numbers since all repdigits are nude. The smallest nude number which contains all the odd digits is \(1117935\). Note that if a nude number contains a \(5\), then all the other digits must be odd. The smallest nude \(n\) which contains the maximal (8) number of distinct digits is \(1123449768\). The smallest triple of consecutive nontrivial nude numbers is \((1111, 1112, 1113)\). It is easy to see that there cannot be four consecutive nude numbers greater than 10.

The entry goes on to depict the smallest 3 × 3 magic square whose entries are nontrivial consecutive nude numbers (that is, not the numbers from 1 to 9). See Figure 1.

Figure 1

It's easy enough to generate all the nude numbers from 1 to 26124 using the SageMath code shown below (permalink to SageMathCell):

L=[]
for n in [1..26124]:
    N=n.digits()
    OK=1
    for i in range(len(N)):
        if N[i]==0:
            OK=0
            break
        else:
            if n%N[i]!=0:
                OK=0
                break
    if OK==1:
        L.append(n)
print(L)
print("The percentage of nude numbers up to",n,"is",numerical_approx(len(L)/n*100,digits=2))

The output tells us that approximately 2.9% of the numbers between 1 and 26124 are nude. Here is output:

[1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15, 22, 24, 33, 36, 44, 48, 55, 66, 77, 88, 99, 111, 112, 115, 122, 124, 126, 128, 132, 135, 144, 155, 162, 168, 175, 184, 212, 216, 222, 224, 244, 248, 264, 288, 312, 315, 324, 333, 336, 366, 384, 396, 412, 424, 432, 444, 448, 488, 515, 555, 612, 624, 636, 648, 666, 672, 728, 735, 777, 784, 816, 824, 848, 864, 888, 936, 999, 1111, 1112, 1113, 1115, 1116, 1122, 1124, 1128, 1131, 1144, 1155, 1164, 1176, 1184, 1197, 1212, 1222, 1224, 1236, 1244, 1248, 1266, 1288, 1296, 1311, 1326, 1332, 1335, 1344, 1362, 1368, 1395, 1412, 1416, 1424, 1444, 1448, 1464, 1488, 1515, 1555, 1575, 1626, 1632, 1644, 1662, 1692, 1715, 1722, 1764, 1771, 1824, 1848, 1888, 1926, 1935, 1944, 1962, 2112, 2122, 2124, 2128, 2136, 2144, 2166, 2184, 2196, 2212, 2222, 2224, 2226, 2232, 2244, 2248, 2262, 2288, 2316, 2322, 2328, 2364, 2412, 2424, 2436, 2444, 2448, 2488, 2616, 2622, 2664, 2688, 2744, 2772, 2824, 2832, 2848, 2888, 2916, 3111, 3126, 3132, 3135, 3144, 3162, 3168, 3171, 3195, 3216, 3222, 3264, 3276, 3288, 3312, 3315, 3324, 3333, 3336, 3339, 3366, 3384, 3393, 3432, 3444, 3492, 3555, 3612, 3624, 3636, 3648, 3666, 3717, 3816, 3864, 3888, 3915, 3924, 3933, 3996, 4112, 4116, 4124, 4128, 4144, 4164, 4172, 4184, 4212, 4224, 4236, 4244, 4248, 4288, 4332, 4344, 4368, 4392, 4412, 4416, 4424, 4444, 4448, 4464, 4488, 4632, 4644, 4824, 4848, 4872, 4888, 4896, 4932, 4968, 5115, 5155, 5355, 5515, 5535, 5555, 5775, 6126, 6132, 6144, 6162, 6168, 6192, 6216, 6222, 6264, 6288, 6312, 6324, 6336, 6366, 6384, 6432, 6444, 6612, 6624, 6636, 6648, 6666, 6696, 6762, 6816, 6864, 6888, 6912, 6966, 6984, 7112, 7119, 7175, 7224, 7266, 7371, 7448, 7476, 7644, 7728, 7777, 7784, 8112, 8128, 8136, 8144, 8184, 8224, 8232, 8248, 8288, 8328, 8424, 8448, 8488, 8496, 8616, 8664, 8688, 8736, 8824, 8832, 8848, 8888, 8928, 9126, 9135, 9144, 9162, 9216, 9288, 9315, 9324, 9333, 9396, 9432, 9612, 9648, 9666, 9864, 9936, 9999, 11111, 11112, 11115, 11122, 11124, 11128, 11133, 11136, 11144, 11155, 11166, 11172, 11184, 11196, 11212, 11222, 11224, 11226, 11232, 11244, 11248, 11262, 11288, 11313, 11316, 11322, 11328, 11331, 11355, 11364, 11412, 11424, 11436, 11444, 11448, 11488, 11515, 11535, 11555, 11616, 11622, 11664, 11676, 11688, 11711, 11824, 11832, 11848, 11872, 11888, 11916, 12112, 12122, 12124, 12126, 12128, 12132, 12144, 12162, 12168, 12184, 12212, 12216, 12222, 12224, 12244, 12248, 12264, 12288, 12312, 12324, 12336, 12366, 12384, 12412, 12424, 12432, 12444, 12448, 12488, 12492, 12612, 12624, 12636, 12648, 12666, 12712, 12726, 12768, 12816, 12824, 12848, 12864, 12888, 12924, 12996, 13113, 13116, 13122, 13128, 13131, 13155, 13164, 13212, 13224, 13236, 13248, 13266, 13272, 13311, 13326, 13332, 13335, 13344, 13362, 13368, 13377, 13392, 13416, 13464, 13488, 13515, 13626, 13632, 13644, 13662, 13713, 13755, 13776, 13797, 13824, 13848, 13896, 13932, 13968, 13995, 14112, 14124, 14128, 14136, 14144, 14184, 14212, 14224, 14232, 14244, 14248, 14288, 14292, 14316, 14328, 14364, 14412, 14424, 14436, 14444, 14448, 14488, 14616, 14664, 14688, 14728, 14784, 14824, 14832, 14848, 14888, 15115, 15135, 15155, 15315, 15515, 15555, 15575, 15715, 16116, 16122, 16128, 16164, 16212, 16224, 16236, 16248, 16266, 16326, 16332, 16344, 16362, 16368, 16416, 16464, 16488, 16626, 16632, 16644, 16662, 16716, 16824, 16848, 16992, 17115, 17122, 17136, 17171, 17199, 17248, 17262, 17444, 17472, 17535, 17717, 17724, 17766, 17955, 18112, 18128, 18144, 18168, 18184, 18216, 18224, 18248, 18264, 18288, 18312, 18336, 18384, 18424, 18432, 18448, 18488, 18624, 18648, 18816, 18824, 18848, 18864, 18872, 18888, 18936, 19116, 19224, 19296, 19332, 19368, 19395, 19692, 19719, 19926, 19935, 19944, 19962, 19971, 21112, 21122, 21124, 21126, 21128, 21132, 21144, 21162, 21168, 21184, 21212, 21216, 21222, 21224, 21244, 21248, 21264, 21288, 21312, 21324, 21336, 21366, 21384, 21412, 21424, 21432, 21444, 21448, 21488, 21492, 21612, 21624, 21636, 21648, 21666, 21672, 21728, 21784, 21816, 21824, 21848, 21864, 21888, 21924, 21996, 22112, 22116, 22122, 22124, 22128, 22144, 22164, 22176, 22184, 22212, 22222, 22224, 22236, 22244, 22248, 22266, 22288, 22326, 22332, 22344, 22362, 22368, 22392, 22412, 22416, 22424, 22444, 22448, 22464, 22488, 22626, 22632, 22644, 22662, 22722, 22764, 22824, 22848, 22888, 22896, 22932, 22968, 23112, 23124, 23136, 23166, 23184, 23226, 23232, 23244, 23262, 23292, 23316, 23322, 23328, 23364, 23412, 23424, 23436, 23448, 23616, 23622, 23664, 23688, 23772, 23832, 23922, 24112, 24124, 24128, 24132, 24144, 24168, 24184, 24192, 24212, 24216, 24224, 24244, 24248, 24264, 24276, 24288, 24312, 24324, 24336, 24384, 24412, 24424, 24432, 24444, 24448, 24472, 24488, 24612, 24624, 24636, 24648, 24696, 24724, 24816, 24824, 24848, 24864, 24888, 24912, 24984, 26112, 26124] 

The percentage of nude numbers up to 26124 is 2.9


Wolfram MathWorld has some auxiliary information:
Numbers in base-10 which are divisible by their digits are 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15, 22, 24, 33, 36, 44, 48, 55, 66, 77, 88, 99, 111, 112, 115, 122, ... (OEIS A034838). Numbers which are divisible by the sum of their digits are called Harshad numbers: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 18, 20, 21, 24, ... (OEIS A005349). Numbers which are divisible by both their digits and the sum of their digits are 1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 24, 36, 48, 111, 112, 126, 132, 135, 144, ... (OEIS A050104). Numbers which are equal to (i.e., not just divisible by) the product of their divisors and the sum of their divisors are called sum-product numbers and are given by 1, 135, 144, ... (OEIS A038369).

Thursday, 8 October 2020

Forming Equations from Integers


Read on!

Once upon a time, before I started this exclusively mathematical blog in 2015, I used to post occasional mathematical content to my Pedagogical Posturing blog at https://voodoo-guru.blogspot.com. I was looking back at some of these posts and noticed this one, from Saturday, 24 August 2013, titled Forming Equations from Integer Sequences. It's only short so I'll quote it in full:

Recently I've been using Twitter to create a daily tweet that records my "day count" (number of days I've been alive) plus its factors (if not prime) and some interesting facts about the number itself or one of its factors. Sometimes there's little to say about the number and in such cases I've found that I can usually form an equation by inserting mathematical operators between one or more of the digits. 

For example, yesterday the count was \(23518\) and \(23 - 5 = 18.\) Today the count is \(23519\) and \(2 + 3 + 5 - 1 = 9\). I was wondering if it's always possible to create an equation from five digits using the standard mathematical operators (addition, subtraction, multiplication, division and exponentiation in combination with brackets). Obviously with just two digits, it's only possible when the digits are repeated e.g. \(99\) becomes \(9 = 9\). With three digits, it's sometimes possible e.g. \(819\) becomes \(8 + 1 = 9\) but generally it isn't e.g. \(219\). With four digits, it's more possible e.g. \(2119\) becomes \(-2 + 11 = 9\) but I'm doubtful whether this is always so. There must come a point however, where the number of digits is sufficient to ensure that it's always so. Maybe five digits is that point.

From now on, I'll try each day to form an equation to test out this theory. For example, tomorrow the count is \(23520\) which becomes \(2+3-5=2 \times 0 \) and it works for tomorrow but beyond that let's see.

Well, I didn't keep my promise of trying to form an equation each day from the digits making up my diurnal age. I have however, written about selfie numbers in a post of Friday, 27th March 2020 to my Mathematical Meanderings blog site. These are somewhat similar in spirit. In that post, I also mention Friedman numbers that can be described as follows:

Consider \(28547 =(8+5)^4−(7 \times 2)\) expressed in base 10, both sides use the same digits. An integer is a Friedman number if it can be put into an equation such that both sides use the same digits but the right hand side has one or more basic arithmetic operators (addition, subtraction, multiplication, division, exponentiation) interspersed. Brackets, as usual, are essential to clarify the order of operations. These numbers are named after Erich Friedman, Assoc. Professor of Mathematics at Stetson University. With the help of his students he has researched Friedman numbers in bases 2 through 10 and even with Roman numerals. When both sides use the digits in the same order, the number is called a ”nice” or ”strong” Friedman number. For example, \( 3125=(3+[1\times2])^5.\)

My approach is similar to this except I'm trying to create an equation from the digits (using them in the same order as they appear in the number). As another example, today I'm \(26121\) days old and this is an easy one because \( (2 \times 6)/12=1 \) if we allow concatenation of digits. If only individual digits are allowed, then \(-(2-6)=1+2+1 \) satisfies. It's probably better to use the individual digits as is done with the Friedman numbers. I'll try to include this as part of my daily number analysis. 

Going back a few days, we have:

  • \(26120 \text{ --> } 2 = \frac{6}{1 + 2 +0} \)
  • \(26119 \text{ --> } 2 + 6 \times 1 = -1 + 9 \)
  • \(26118 \text{ --> } 2 + 6 + 1 = 1 + 8 \)
  • \(26117 \text{ --> } 2 + 6 = 1 \times 1 + 7 \)
  • \(26116 \text{ --> } 2 + 6 = 1 + 1 + 6 \)
  • \(26115 \text{ --> } -2 + 6 + 1 \times 1 = 5 \)
  • \(26114 \text{ --> } -2 + 6 = 1 - 1 + 4 \)
  • \(26113 \text{ --> } -2 + 6 = 1 \times 1 + 3 \)
  • \(26112 \text{ --> } -2 + 6 = 1 + 1 + 2 \)
  • \(26111 \text{ --> } 2 = \frac{6}{1+1+1}\)
  • \(26110 \text{ --> } 2 \times 6 \times (1-1) = 0 \)
It seems that it's always possible to form an equation using only brackets and the basic arithmetic operators of addition, subtraction, multiplication, division and exponentiation. Perhaps even the exponentiation is not needed, as the examples above show. Let's see if this assumption holds true for future numbers. This is hardly high level mathematics but it's a simple yet oddly satisfying activity.

Tuesday, 6 October 2020

Honaker: Primes and Problem

Figure 1
G. L. Honaker Jr is a rather shadowy figure who, as we learn from his LinkedIn profile, is a Maths/Science graduate who has been teaching for 28 years. He lives in Bristol, Virginia, and must be around 50 years old. There's not much other biographical data about him, except that he is the co-author of a book that I'll talk about later.

The reason I mention him is that his name came up today as part of my diurnal age number investigation. Today I'm 26119 days old and this turns out to be a Honaker prime. It's pretty cool to have a type of prime number named after you. So what is a Honaker prime? It's defined as a prime \(p_n\) whose index \(n\) and \(p_n\) itself have the same sum of digits. For example, \(p_{32}=131\) is a Honaker prime because \(3+2=1+3+1\).

Unlike primeness, the property that defines a Honaker prime is base specific. For example in base 2, 32 becomes 100000 and 131 becomes 10000011, but the sums of their digits are different. The smallest prime which is Honaker in all the bases from 2 to 10 is  \(p_{277308991}= 5949670231\). I'm thankful to NumbersAplenty for this information.

Not only does Honaker have a type of prime named after him, he also has an eponymous problem. Wolfram MathWorld explains that Honaker's problem asks for all consecutive prime number triples \((p,q,r)\) with \(p<q<r\) such that \(p|(qr+1)\). Caldwell and Cheng (2005) showed that the only Honaker triplets for \(p<=2×10^{17} \text{ are }(2, 3, 5), (3, 5, 7) \text{ and } (61, 67, 71)\). It is conjectured that these three triplets may be the only such triplets with this property.

Interestingly, I'm currently 71 years old and 71 forms part of a Honaker triplet in addition to the fact that my diurnal age (26119) is a Honaker prime. Now getting back to Honaker's book that is available on Amazon. There is an accompanying website that boasts that "there are currently 25464 curios corresponding to 18548 different numbers in our database, that leaves an infinite number for you to discover!"

Naturally I typed in 26119 and discovered that "The number of Honaker primes less than or equal to 26119 is the smallest Honaker prime." This indeed true as the smallest Honaker prime is 131 and there are exactly 131 Honaker primes less than or equal to 26119. I was impressed. Clearly, this is a book to buy and a website to visit for anyone seriously interested in prime numbers.

Saturday, 26 September 2020

RATS Sequence

Today I turned 26109 days old and one of the properties of this number is that its a member of OEIS A114613:


A114613

Starting numbers for which the RATS sequence has eventual period 3.



The comments in the OEIS entry offered no explanation but there was a link to Eric Weisstein's World of Mathematics, RATS Sequence

A sequence produced by the instructions "reverse, add to the original, then sort the digits." For example, after 668, the next iteration is given by

668+866=1534

so the next term is 1345.

Applied to 1, the sequence gives: 

1, 2, 4, 8, 16, 77, 145, 668, 1345, 6677, 13444, 55778, 133345, 666677, 1333444, 5567777, 12333445, 66666677, 133333444, 556667777, 1233334444, 5566667777, 12333334444, 55666667777, 123333334444, 556666667777, 1233333334444, ... (OEIS A004000).

Conway conjectured that an initial number leads to a divergent period-two pattern (such as the above in which the numbers of threes and sixes in the middles of alternate terms steadily increase) or to a cycle (Guy 2004, p. 404).

The lengths of the cycles obtained by starting with \(n\)= 1, 2, ... are 0, 0, 8, 0, 0, 8, 0, 0, 2, 0, ... (OEIS A114611), where a 0 indicates that the sequence diverges.

The following table summarizes the first few values of \(n\) leading to a period of length \(k\). There are no other periods of length 50 or less for \(n \leq 5 \times 10^7\).

 (E. W. Weisstein, Dec. 19, 2005). 

\(k\)OEIS\(n\) with period \(k\)
A001651  1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20, ...
2A1146129, 18, 27, 36, 45, 54, 63, 69, 72, 78, 81, 87, 90, 96, ...
3A11461320169, 20709, 21159, 22149, 23139, 24129, 25119, 26109, ...
8A1146143, 6, 12, 15, 21, 24, 30, 33, 39, 42, 48, 51, 57, 60, 66, ...
14A1146156999, 7089, 7179, 7269, 7359, 7449, 7539, 7629, ...
18A11461629, 38, 47, 49, 56, 58, 65, 67, 74, 76, 83, 85, 92, 94, ...

In the case of 26109, it can seen from the following SageMath code that the instructions do indeed lead to a period with length 3 (permalink):

number=26109
L=[number]
while len(L)==Set(L).cardinality():
    N=number.digits()
    reversal=0
    for n in range(0, len(N)):
        reversal+=N[n]*10^(len(N)-n-1)
    number=number+reversal
    D=sorted(number.digits())
    index, number=0,0
    for d in D:
        number+=d*10^(len(D)-index-1)
        index+=1
    L.append(number)
print(L)

[26109, 111267, 337788, 1122255, 4446666, 1111113, 2222244, 4446666]

Here is a little more background surrounding this sequence, taken from this site:

Princeton mathematician John Horton Conway calls this the RATS sequence (for “reverse, add, then sort”) and in 1989 conjectured that no matter what number you start with (in base 10), you’ll either enter the divergent pattern above or find yourself in some cycle. Conway’s colleague at Princeton, Curt McMullen, showed that the conjecture is true for all numbers less than a hundred million, and himself conjectured that every RATS sequence in bases smaller than 10 is eventually periodic. Are they right? So far neither conjecture has been disproved. 

There seems to be however, another version of the RATS sequence with members generated using the following rule:

Write down an integer. Remove any zeros and sort the digits in increasing order. Now add this number to its reversal to produce a new number, and perform the same operations on that and so on. Source.

Applying this to 26109, we see that it does produce a loop but its period is 2 (1170 --> 828 --> 1170) not 3 (4446666 --> 1111113 --> 2222244 --> 4446666) as was the case with our original steps:

26109 —> 2619 —> 1269 —> 1269 + 9621 —> 10890

10890 —> 189 —> 189 + 981 —> 1170

1170 —> 117 —> 117 + 711 —> 828

828 —> 288 —> 288 + 882 —> 1170 

 The original instructions are more straightforward and don't require removal of any zeroes. 

Monday, 21 September 2020

Magic Squares

This post was inspired by my daily number analysis of my diurnal age. I was struggling to find something of interest about 26102 when I discovered that a \(4 \times 4 \) magic square could be created in which 26102 was the magic constant. This got me thinking about what numbers could be represented in this way as magic squares.

A \(n \times n \) magic square has its \(n^2\) cells filled with the numbers from \(1 \text{ to } n^2 \) in such a way that the sums of all rows, columns and main diagonals are the same. This sum is called the magic constant:$$ \frac{n(n^2+1)}{2}$$The \(3 \times 3 \) magic square contains the numbers from 1 to 9 and all rows, columns and main diagonals add up to 15. Thus the magic constant is 15.$$


\begin{array}{|c|c|c|}

\hline 8 & 1 & 6 \\

\hline 3 & 5 & 7\\

\hline 4 & 9 & 2 \\

\hline

\end{array}

$$If we add 1 to each element of the above magic square, we get the next magic square and this has a magic constant of 18:$$\begin{array}{|c|c|c|}

\hline 9 & 2 & 7 \\

\hline 4 & 6 & 8\\

\hline 5 & 10 & 3 \\

\hline

\end{array}$$All subsequent \(3 \times 3 \) magic squares will have magic constants that are multiples of 3. Thus the number 26097 = 3 x 8699 can be represented as:$$\begin{array}{|c|c|c|}

\hline 8702 & 8695 & 8700 \\

\hline 8697 & 8699 & 8701\\

\hline 58698 & 8703 & 8696 \\

\hline

\end{array}$$We could represent the various matrices in terms of a subscript for their size and a superscript for their magic sum. This is purely my own invention but it means we would have: M\(_3^{15}\)M\(_3^{18}\) and M\(_3^{26097} \) where M is any matrix that satisfies the condition of being magic and having a particular size and magic sum. The \(4 \times 4\) magic square containing the numbers 1 to 15 has a magic sum of 34:$$\begin{array}{|c|c|c|c|}

\hline 16 & 2 & 3 & 13 \\

\hline 5 & 11 & 10 & 8\\

\hline 9 & 7 & 6 & 12 \\


\hline 4 & 14 & 15 & 1 \\

\hline

\end{array}$$It would be designated as M\(_4^{34}\) in my system. The subsequent magic sums that are possible are 38, 42, 46, 50 and so on. To test whether a number can be the magic constant for a \(4 \times 4\) magic square, simply subtract 34 from the number and test whether the result is divisible by 4. In the case of 26102, it is and so we have:$$\begin{array}{|c|c|c|c|}\hline 6533 & 6519 & 6520 & 6530 \\


\hline 6522 & 6528 & 6527 & 6525\\

\hline 6526 & 6524 & 6523 & 6529 \\


\hline 6521 & 6531 & 6532 & 6518 \\

\hline

\end{array}$$This magic square can be designated M\(_4^{26102}\). Figures 1 and 2 shows the magic squares together with their magic sums and associated planet or luminary.

Figure 1: source


Figure 2: source

The \(5 \times 5 \) magic square has a constant of 65 and so any subsequent multiples of 5 will be representable as \(5 \times 5 \) magic squares. The \(6 \times 6 \) magic square has a constant of 111 which is 3 x 37. This means that 117, 123, 129 etc. can be represented as \(6 \times 6 \) magic squares but these numbers are not multiples of 6. To determine whether a number can be the magic constant for a \(6 \times 6 \) magic square, the 111 must first be subtracted and the result tested for divisibility by 6. This is like the \(4 \times 4 \) case.

For the \(7 \times 7 \) magic square, the constant is 175 = 7 x 25 and so any multiple of 7 can be represented by a \(7 \times 7 \) magic square. For the \(8 \times 8 \) magic square, the constant is 260 = 4 x 65 which is not divisible by 8 and the situation is as the same as with 4 and 6. For the \(9 \times 9 \) magic square, the constant is 369 = 9 x 41 so all multiples of 9 above 369 qualify.

Figure 3 shows the magic constants for larger magic squares:


Figure 3: source

So generally, excluding 2, the prime factorisation of a number will quickly tell us what magic squares it can serve as a constant for. For example, 910 = 2 * 5 * 7 * 13 and so it can be represented by magic squares of side 5, 7 and 13. It can also be represented as a magic square with a composite number of sides but a little testing is required. For example, it can be represented as a \(4 \times 4 \) magic square but not \(8 \times 8 \). This site is great for such testing.

on May 14th 2021

Saturday, 12 September 2020

Root-Mean-Square And Other Means

Today I turned 26095 days old and this number happens to be a so-called RMS number where RMS stands for Root-Mean-Square. Such numbers are defined by OEIS A140480 as numbers \(n\) such that root mean square of divisors of \(n\) is an integer. Now the root mean square of divisors is defined by MathWorld as:

For a set of \(n\) numbers or values of a discrete distribution \(x_i, ..., x_n\), the root-mean-square (abbreviated "RMS" and sometimes called the quadratic mean), is the square root of mean of the values \(x_i^2\), namely:$$x_{RMS}=\sqrt{\frac{x_1^2+x_2^2+...+x_n^2}{n}}=\sqrt{\dfrac{\sum \limits_{i=1}^n x_i^2}{n}}$$For a variate \(\chi\) from a continuous distribution \(P(x)\), we have:$$x_{RMS}=\sqrt{ \frac{\int[P(x)]^2 dx}{\int P(x) \,dx}}$$where the integrals are taken over the domain of the distribution. Similarly, for a function \(f(t)\) periodic over the interval \([T_1,T_2]\), the root-mean-square is defined as:$$f_{RMS}=\sqrt{\frac{1}{T_2-T_1}\int_{T_1}^{T_2} [f(t)]^2 dt}$$

The sequence to which 26095 belongs runs 1, 7, 41, 239, 287, 1673, 3055, 6665, 9545, 9799, 9855, 21385, 26095, ... with 7, 41 and 239 being prime and the next prime being 9369319. Such primes are known as NSW primes, after Newman, Shanks, and Williams (the authors of a paper on the subject back in 1981). If we designate \(n\) to be such a prime number, then \(n\) has 2 divisors \([1, n]\) and we have to solve Pell's equation \(n^2 = 2*C^2 - 1\) where \(C\) is a positive integer. The solution is a prime \(n\) of the form \(u_i = 6u_{i-1} - u_{i-2} \), where \(i \geq 2, u_0=1, u_1=7\). These primes are listed in OEIS A088165.

There are of course many other types of means including arithmetic, geometric, harmonic, Pythagorean, power, Heronian, Identric, population, Chisini, Stolarsky, Lehmer, weighted and so on. The arithmetic mean is certainly the best known and most widely used but the root-mean-square has many applications in scientific circles. I've encountered the root-mean-square before in the context of the root-mean-square-error (see Figure 1).


Figure 1

A regression line is a line drawn such that the RMSE is minimised (see Figure 2).

Figure 2

The root-mean-square is a particular instance of a more generalised power mean defined as:$$M_p(a_1, a_2, ..., a_n) \equiv \bigg( \frac{1}{n} \sum_{k=1}^n a_k^{\,p} \bigg)^{1/p} $$where the parameter \(p\) is an affinely extended real number and all \(a_k \geq 0\). A power mean is also known as a generalized mean, Hölder mean, or mean of degree (or order or power) \(p\). The case of \(p=1\) is the arithmetic mean and the case of \(p=2\) is the root-mean-square. 

Figure 3 shows a summary of a few particular values of \(p\) that yield special cases with their own names (source):

Figure 3

The three "classic" means \(A\) (the arithmetic mean), \(G\) (the geometric mean), and \(H\) (the harmonic mean) are sometimes known as the Pythagorean means. Figure 4 shows how these means on two elements \(a\) and \(b\) could be constructed geometrically, and also demonstrates that \(H \leq G \leq A\).


Figure 4: source

Wednesday, 2 September 2020

Factorial Number System

I've titled this post Factorial Number System because I made a post titled Factorial Number Base on 31st March 2018. Strictly speaking, the factorials do not form a number base. This is explained in Wikipedia:

In combinatorics, the factorial number system, also called factoradic, is a mixed radix numeral system adapted to numbering permutations. It is also called factorial base, although factorials do not function as base, but as place value of digits. By converting a number less than n! to factorial representation, one obtains a sequence of \(n\) digits that can be converted to a permutation of \(n\) in a straightforward way, either using them as Lehmer code or as inversion table representation; in the former case the resulting map from integers to permutations of \(n\) lists them in lexicographical order. General mixed radix systems were studied by Georg Cantor. The term "factorial number system" is used by Knuth, while the French equivalent "numération factorielle" was first used in 1888. The term "factoradic", which is a portmanteau of factorial and mixed radix, appears to be of more recent date.

My interest in the subject was rekindled when I came across this OEIS entry for 26085 (I turned 26085 days old today):

A286590: Numbers that are divisible by the product of their factorial base digits (A208575).

In my 2018 post, I treated this number system rather narrowly so I am broadening my scope in this current post. Figure 1 shows an easy way to convert from a decimal number to its factorial representation:


Using this method, the following SageMath code will carry out the conversion (input is shown in blue and output in red):

# -------------------------------------------------------
# decimal to factorial base conversion with trailing zero
# -------------------------------------------------------
number=26085
entry=number
L,n,dividend=[],1,1
while dividend!=0:
    dividend=int(number/n)
    remainder=number%n
    L.append(remainder)
    number=dividend
    n+=1
L.reverse()
print(entry,"has factorial base of",L, "with trailing zero")
# ----------------------------------------------------------
# decimal to factorial base conversion without trailing zero
# ----------------------------------------------------------
number=26085
L,n,dividend=[],2,1
while dividend!=0:
    dividend=int(number/n)
    remainder=number%n
    L.append(remainder)
    number=dividend
    n+=1
L.reverse()
print(entry,"has factorial base of",L, "without trailing zero")  
 
26085 has factorial base of [5, 1, 1, 1, 3, 1, 1, 0] with trailing zero
26085 has factorial base of [5, 1, 1, 1, 3, 1, 1] without trailing zero

Here is the permalink to SageMathCell. Notice the two possible representations: \(51113110_!\) and   \(5111311_!\). This is because "The factorial number system is sometimes defined with the 0! place omitted because it is always zero" (Wikipedia). The conversion from factorial representation to decimal is quite straightforward. Here is the SageMath code (permalink):

# ---------------------------------------------------------
# factorial base (with trailing zero) to decimal conversion 
# ---------------------------------------------------------
number=51113110
D=number.digits()
decimal,n=0,0
for d in D:
    decimal+=d*factorial(n)
    n+=1
print(decimal)
# ------------------------------------------------------------
# factorial base (without trailing zero) to decimal conversion 
# ------------------------------------------------------------
number=5111311
D=number.digits()
decimal,n=0,1
for d in D:
    decimal+=d*factorial(n)
    n+=1
print(decimal)

26085
26085

Wikipedia goes on to say:
The factorial number system provides a unique representation for each natural number, with the given restriction on the "digits" used. No number can be represented in more than one way because the sum of consecutive factorials multiplied by their index is always the next factorial minus one:$$\sum_{i=0}^n i \times i!=(n+1)!-1$$
This can be easily proved with mathematical induction, or simply by noticing that :$$\forall i,i \times i!=(i+1-1) \times i!=(i+1)!-i!$$where subsequent terms cancel each other, leaving the first and last term (see Telescoping series).
However, when using Arabic numerals to write the digits (and not including the subscripts as in the above examples), their simple concatenation becomes ambiguous for numbers having a "digit" greater than 9. The smallest such example is the number 10 × 10! = 36,288,00010, which may be written A0000000000!=10:0:0:0:0:0:0:0:0:0:0!, but not 100000000000! = 1:0:0:0:0:0:0:0:0:0:0:0! which denotes 11! = 39,916,80010. Thus using letters A–Z to denote digits 10, 11, 12, ..., 35 as in other base-N make the largest representable number 36 × 36! − 1. 
For arbitrarily greater numbers one has to choose a base for representing individual digits, say decimal, and provide a separating mark between them (for instance by subscripting each digit by its base, also given in decimal, like 24031201, this number also can be written as 2:0:1:0!). In fact the factorial number system itself is not truly a numeral system in the sense of providing a representation for all natural numbers using only a finite alphabet of symbols, as it requires an additional separation mark.

There's a lot more that could be said about this topic and I may add to it in the future. In conclusion, DCODE provides a quick conversion tool from decimal to factorial base and back again. It's an interesting site that I've used before but had forgotten about. It's a site well worth exploring.