# Programmatic Mathematica XVI: Patterns in Highly Composite Numbers

This article was inspired by a vlog from Numberphile, on the discussion of “5040: an anti-prime number”, or some title like that.

A contributor to the OEIS named Jean-François Alcover came up with a short bit of Mathematica code that I modified slightly:

```Reap[
For[
record = 0; n = 1, n <= 110880, n = If[n < 60, n + 1, n + 60], tau = DivisorSigma[0, n];
If[tau > record, record = tau; Print[n, "\t\t", tau];
Sow[tau]]]][[2, 1]]
```

This generates a list of a set of numbers with an unusually high amount of factors called “highly composite numbers” up to 110,880. The second column of the output are the number of factors.

```1      1
2       2
4       3
6       4
12      6
24      8
36      9
48      10
60      12
120     16
180     18
240     20
360     24
720     30
840     32
1260        36
1680        40
2520        48
5040        60
7560        64
10080       72
15120       80
20160       84
25200       90
27720       96
45360       100
50400       108
55440       120
83160       128
110880      144
```

For a number like 110,880, there is no number before it that has more than 144 factors.

Highly composite numbers (HCNs) are loosely defined as a natural number which has more factors than any others that came before it. 12 is such a number, with 6 factors, as is 6 itself with 4. The number 5040 has 60 factors, and is also considered highly composite.

5040=24×32×5×7
This works out to 60, because with 24, for example, we get the factors 2, 4, 8, and 16. With 24×32, we get 2, 3, 4, 6, 8, 9, 16, 18, 36, 72, and 144, all which evenly divide 5040. The total number of factors including 1 and 5040 itself can be had from adding 1 to each exponent and multiplying: (4+1)(2+1)(1+1)(1+1)=5×3×2×2=60.

Initially, facotorization of HCNs was done in Maple using the “ifactor()” command. But there is a publication circulating the Internet referring to a table created by Ramanujan that has these factors. A partial list of these are summarized in a table below. The top row headers are the prime numbers that can be the prime factors, from 2 to 17. The first column is the number to factorize. The numbers in the same columns below these prime numbers are the exponents on the primes, such as: 10,080=25×32×51×71. The last column are the total number of factors on these HCNs. So, by adding 1 to each exponent in the row and multiplying, we find that 10,080 has 6×3×2×2=72 factors.

###### NUMBER PATTERNS OBSERVED

As a number of factors (underneath the “# facotrs” column), We get overlapping patterns starting from 60. One of them would be the sequence: 120, 240, 360, 480, 600, and 720. But the lack of an 840 breaks that pattern. But then we get 960, then 1080 is skipped, but then we get 1200.

For numbers of factors that are powers of 2, it seems to go right off the end of the table and beyond: 64, 128, 256, 512, 1024, 2048, 4096, 8192, … . Before 5040, the pattern is completed, since 2 has 2 factors, 6 has 4 factors, 24 has 8 factors, 120 has 16 factors, and 840 has 32 factors. The HCN with 8192 factors is 3,212,537,328,000. We have to go beyond that to see if there is a number with 16,384 factors.

Multiples of 12 make their appearance as numbers of factors: 12, 24, 36, 48, 60 (which are the numbers of factors of 5040), 72, 84, 96, 108, 120, but a lack of a 132 breaks that pattern. But then we see: 144, 288, 432, 576, 720, 864, 1008, 1152, and the pattern ends with the lack of a 1296.

We also observe short runs of numbers of factors in the sequence 100, 200, 400, 800, until we reach the end of this table. But the pattern continues with the number 2,095,133,040, which has 1600 factors. Then, 3200 is skipped.

There are also multiples of 200: 200, 400, 600, 800, but the lack of a 1000 breaks that pattern. But when seen as multiples of 400, we get: 400, 800, 1200, 1600, but then 2000 is skipped.

There are also peculiarities in the HCNs themselves. Going from 5040 to as high as 41,902,660,800, only 4 of the 60 HCNs were not multiples of 5040. The rest had the remainder 2520, which is one-half of 5040.

Also beginning from the HCN 720,720, we observe a run of numbers containing 3-digit repeats: 1081080, 1441440, 2162160, 2882880, 3603600, 4324320, 6486480, 7207200, 8648640, 10810800, and 14414400.

```Number 2   3   5   7   11  13  17  # of
factors
-----------------------------------------------------------------------
5040    4   2   1   1               60
7560    3   3   1   1               64
10080   5   2   1   1               72
15120   4   3   1   1               80
20160   6   2   1   1               84
25200   4   2   2   1               90
27720   3   2   1   1   1           96
45360   4   4   1   1               100
50400   5   2   2   1               108
55440   4   2   1   1   1           120
83160   3   3   1   1   1           128
110880  5   2   1   1   1           144
166320  4   3   1   1   1           160
221760  6   2   1   1   1           168
332640  5   3   1   1   1           192
498960  4   4   1   1   1           200
554400  5   2   2   1   1           216
665280  6   3   1   1   1           224
720720  4   2   1   1   1   1       240
1081080 3   3   1   1   1   1       256
1441440 5   2   1   1   1   1       288
2162160 4   3   1   1   1   1       320
2882880 6   2   1   1   1   1       336
3603600 4   2   2   1   1   1       360
4324320 5   3   1   1   1   1       384
6486480 4   4   1   1   1   1       400
7207200 5   2   2   1   1   1       432
8648640 6   3   1   1   1   1       448
10810800    4   3   2   1   1   1       480
14414400    6   2   2   1   1   1       504
17297280    7   3   1   1   1   1       512
21621600    5   3   2   1   1   1       576
32432400    4   4   2   1   1   1       600
61261200    4   2   2   1   1   1   1   720
73513440    5   3   1   1   1   1   1   768
110270160   4   4   1   1   1   1   1   800
122522400   5   2   2   1   1   1   1   864
147026880   6   3   1   1   1   1   1   896
183783600   4   3   2   1   1   1   1   960
245044800   6   2   2   1   1   1   1   1008
294053760   7   3   1   1   1   1   1   1024
367567200   5   3   2   1   1   1   1   1152
551350800   4   4   2   1   1   1   1   1200
```

After that run, we see a 4-digit overlapping repeat. The digits of the HCN 17297280 could be thought of as an overlap of 1728 and 1728 to make 1729728 as part of that number. The 3-digit run continues with: 21621600, 32432400, 61261200, and after that the pattern is broken.

# Contributions to LibriVox

I have been contributing my voice to public domain audiobooks on Librivox as a bit of a hobby. As one would expect, my bent is toward science and math, and one full recording I made, ready for consumption, is the eighth lecture on General Dynamics by Max Planck. Hear about space-time as only a contemporary of the theory can tell it!

A much longer recording of a 400-page book by Rouse Ball on the History of Mathematics is in progress. I picked up a lot of math and physics from reading both of these books. He goes, as many of these writers do, from antiquity to “modern times”, which for him end at around the year 1890, the decade of the book’s publication.

# VIII: The Programmatic Side of Mathematica: Sampling With Replacement

Arrays. I can declare an array and return an arbitrary element from it:

```S := {2,4,6,8,10}
S[[3]]
6```

I can also do the same things for an anonymous array:

```{2,4,6,8,10}[[3]]
6```

In both cases, I request the third element of the array in double square brackets, and Mathematica returns with the number 6. I can request a random element as was shown in previour posts, but it would be better to name the array:

`S[[Random[Integer,{1,Length[S]}]]]`

The above statement returns a random element from an array without needing to know the length of the array. I could include it in my bag of tricks, since it would resemble sampling, especially if I sample a certain number of times.

Sampling with replacement means picking an element e from a set S without removing it. With sets, that amounts to just choosing elements from a set while allowing repetition. We don’t even need numbers. What about letters? Let’s re-define the set S thusly:

`S:={a,b,c,d,e,f,g,h,i,j,k,l}`

Now, let’s define a function called “pick[n]” which chooses some quantity of letters from S by passing the number of choices to it as “n”:

`pick[n_]:=Table[S[[Random[Integer,{1,Length[S]}]]],{n}]`

That’s a lot of nested brackets. But recall that the Table[] function generated a set of size n by executing the function in the first parameter n times, and returning the result as an array. But here, the function is passed into the Random[] function, which determines the array index of the element chosen from S. So, two calls to pick returned these for me:

```pick[4]
{b,e,a,d}
pick[4]
{h,g,h,d}```

So, as you can see, we have repetition.