Showing posts with label asymptotic density. Show all posts
Showing posts with label asymptotic density. Show all posts

Monday, 21 November 2022

Tau Numbers

Having just posted about anti-tau numbers, I realised that I hadn't yet made a dedicated post about tau numbers and in fact only mentioned them briefly in a post titled Arithmetic Numbers. In this post, I'll address that deficiency. 

Wikipedia has the following definition:

A refactorable number or tau number is an integer \(n\) that is divisible by the count of its divisors, or to put it algebraically, \(n\) is such that \( \tau (n) \mid n \). The first few refactorable numbers are listed in OEIS A033950 as:

1, 2, 8, 9, 12, 18, 24, 36, 40, 56, 60, 72, 80, 84, 88, 96, 104, 108, 128, 132, 136, 152, 156, 180, 184, 204, 225, 228, 232, 240, 248, 252, 276, 288, 296, ...

For example, 18 has 6 divisors (1 and 18, 2 and 9, 3 and 6) and is divisible by 6. There are infinitely many refactorable numbers.

Up to 100,000, there are 5257 tau numbers representing 5.257% of the range. However, the article points out that these numbers have a natural density of zero. Another Wikipedia article explains what is meant by this term:

In number theory, natural density (also referred to as asymptotic density or arithmetic density) is one method to measure how "large" a subset of the set of natural numbers is. It relies chiefly on the probability of encountering members of the desired subset when combing through the interval [1, \(n\)] as \(n\) grows large.

Intuitively, it is thought that there are more positive integers than perfect squares, since every perfect square is already positive, and many other positive integers exist besides. However, the set of positive integers is not in fact larger than the set of perfect squares: both sets are infinite and countable and can therefore be put in one-to-one correspondence. Nevertheless if one goes through the natural numbers, the squares become increasingly scarce. The notion of natural density makes this intuition precise for many, but not all, subsets of the naturals (see Schnirelmann density, which is similar to natural density but defined for all subsets of \( \mathbb{N} \).

If an integer is randomly selected from the interval [1, \(n\)], then the probability that it belongs to A is the ratio of the number of elements of A in [1, \(n\)] to the total number of elements in [1,\( n\)]. If this probability tends to some limit as \(n\) tends to infinity, then this limit is referred to as the asymptotic density of A. This notion can be understood as a kind of probability of choosing a number from the set A. Indeed, the asymptotic density (as well as some other types of densities) is studied in probabilistic number theory.

It has been proven that there are no three consecutive integers that are all tau numbers. They can appear in pairs however, although not often. For example, up to 100,000, there are only 13 such pairs. These are:

(1, 2), (8, 9), (1520, 1521), (50624, 50625), (62000, 62001), (103040, 103041), (199808, 199809), (221840, 221841), (269360, 269361), (463760, 463761), (690560, 690561), (848240, 848241), (986048, 986049)

Take the last pair as an example:

\(986048 = 2^6 \times 7 \times 31 \times 71\) with \(56\) divisors such that \( 56 \mid 986048= 17608\)

\(986049 = 3^2 \times 331^2\) with \(9\) divisors such that \(9 \mid 986049= 109561\)

Whether there are an infinite number of such pairs is not known. Numbers Aplenty states that the smallest Pythagorean triple of tau numbers is (40, 96,104) which is not a primitive triple because it is a multiple of (5, 12, 13).  No one knows if there is a primitive triple.

Up to one million, there are 60 palindromic tau numbers. They are:

[1, 2, 8, 9, 88, 232, 252, 424, 444, 636, 808, 828, 2772, 4224, 12321, 21512, 21612, 23032, 23832, 24642, 25352, 25452, 27372, 29292, 40104, 40904, 42324, 42424, 42624, 44244, 46164, 46264, 46464, 48084, 48384, 48584, 48684, 61416, 61816, 63036, 63636, 65856, 67476, 67576, 69396, 69896, 80508, 82428, 84248, 84948, 86168, 86868, 88188, 88488, 216612, 270072, 423324, 426624, 468864, 486684]

Again, up to one million, there are also 2731 non-palindromic tau numbers whose reversals are also tau numbers. The first such number is 80 with reversal 8. The initial members of this sequence are:

80, 276, 288, 468, 480, 672, 864, 880, 882, 1440, 1656, 2000, 2025, 2148, 2160, 2176, 2178, 2196, 2320, 2388, 2700, 2988, 4044, 4050, 4068, 4080, 4240, 4284, 4404, 4668, 4824, 4856, 4860, 4896, 5202, 5220, 6561, 6584, 6712, 6720, 6912, 6984, 8080, 8100, 8412, 8604, 8649, 8664, 8712, 8832, 8892, 9468, 10000, ... permalink

It should be noted that \( \tau(n)=\sigma(n,0)\) and so this function can be used as an alternative to len(divisors(\(n\))) in any calculations.

There's an interesting history associated with the term refactorable number. To quote again from the Wikipedia article:

First defined by Curtis Cooper and Robert E. Kennedy where they showed that the tau numbers have natural density zero, they were later rediscovered by Simon Colton using a computer program he had made which invents and judges definitions from a variety of areas of mathematics such as number theory and graph theory. Colton called such numbers "refactorable". While computer programs had discovered proofs before, this discovery was one of the first times that a computer program had discovered a new or previously obscure idea. Colton proved many results about refactorable numbers, showing that there were infinitely many and proving a variety of congruence restrictions on their distribution. Colton was only later alerted that Kennedy and Cooper had previously investigated the topic.

Note that \(\tau\) is sometimes used to refer to \(2 \times \pi\) but that usage has nothing to do with this post. 

Friday, 23 July 2021

Pandigital Numbers Formed From Squares

As the natural numbers become larger, it's more and more likely that they will contain all of the digits from 1 to 9 at least once. This is why the sequence of numbers containing all the digits from 1 to 9 is said to have an asymptotic density of 1. This is OEIS A294661:


 A294661



Numbers whose square contains all of the digits 1 through 9.   


The sequence begins:
11826, 12363, 12543, 14676, 15681, 15963, 18072, 19023, 19377, 19569, 19629, 20316, 22887, 23019, 23178, 23439, 24237, 24276, 24441, 24807, 25059, 25572, 25941, 26409, 26733, 27129, 27273, 29034, 29106, 30384, 32043, 32286, 33144, 34273, 35172, 35337, 35713, 35756, 35757, 35772, 35846, 35853, ...

I've marked the first thirty members of this sequence in blue because these numbers constitute OEIS A071519:


 A071519

Numbers whose square is a zeroless pandigital number (i.e., use the digits 1 through 9 once).


Beyond 30384 (the 30th and last member of OEIS A071519), some of the digits occur more than once or a zero appears. For example: $$32043^2=1026753849 \text{ and a zero appears}$$There are 362,880 ways of arranging of the digits from 1 to 9 (factorial 9 or 9!). However, only 30 of the resulting numbers are perfect squares and these are listed in OEIS A071519. None of them are prime.

Numbermatics representation of 26409

Today my diurnal age is 26409 and this number is a member of OEIS A071519, which is what drew my attention to the number's property:


If we allow zero and consider possible permutations of the digits from 0 to 9, there are 3,265,920 possibilities (9 x 9!) but only 87 are perfect squares and again, none are prime. All are divisible by 9. These 87 numbers form OEIS A156977:


 A156977

Numbers \(n\) such that \(n^2\) contains every decimal digit exactly once. 


The numbers are:
32043, 32286, 33144, 35172, 35337, 35757, 35853, 37176, 37905, 38772, 39147, 39336, 40545, 42744, 43902, 44016, 45567, 45624, 46587, 48852, 49314, 49353, 50706, 53976, 54918, 55446, 55524, 55581, 55626, 56532, 57321, 58413, 58455, 58554, 59403, 60984, 61575, 61866, 62679, 62961, 63051, 63129, 65634, 65637, 66105, 66276, 67677, 68763, 68781, 69513, 71433, 72621, 75759, 76047, 76182, 77346, 78072, 78453, 80361, 80445, 81222, 81945, 83919, 84648, 85353, 85743, 85803, 86073, 87639, 88623, 89079, 89145, 89355, 89523, 90144, 90153, 90198, 91248, 91605, 92214, 94695, 95154, 96702, 97779, 98055, 98802, 99066

On July 9th 2018, I wrote about Pandigital Numbers Formed From the Product of a Number and its Reversal.

Saturday, 16 January 2021

Asymptotic Density of Happy Go Lucky Numbers

The term happy go lucky means cheerfully unconcerned about the future. A happy-go-lucky person does not plan much and accepts what happens without becoming worried. While we may not all be able to share in this happy state most of the time, we can at least enjoy happy go lucky days on a fairly regular basis. 

If we consider our diurnal age, then on certain days our age in days will be what is termed a happy go lucky number. What criteria are used to determine such a number. Well, for a number to be happy, it must satisfy the criterion that repeated sums of squares of digits lead to 1. If it doesn't the number is destined to enter an endless loop. For a number, this is obviously not a happy situation because there is no finality or resolution to its predicament. I wrote about these in a post dated June 26th 2018.

The loop consists of the numbers 4, 16, 37, 58, 89, 145, 42 and 20 with 20 of course leading back to 4. Let's look at an example of an unhappy number. Tomorrow I'll be 26222 days old. That's a lot of 2's. Working with sums of squares of digits, we find that:$$ \begin{align}26222 \rightarrow 2^2+6^2+2^2+2^2+2^2 &=52\\52 \rightarrow 5^2+2^2&=29\\29 \rightarrow 2^2+9^2&=85\\85 \rightarrow 8^2+5^2&=89 \end{align}$$and we've entered the loop, although we knew that would happen at 85 because by reversing the digits we get 58 which is in the loop. However, today I'm 26221 days old and we find that:$$\begin{align} 26221 \rightarrow 2^2+6^2+2^+2^2+1^2&=49\\49 \rightarrow 4^2+9^2&=97\\97 \rightarrow 9^2+7^2&=130\\130 \rightarrow 1^2+3^2+0^2&=10\\10 \rightarrow 1^2+0^2&=1 \end{align}$$and we've reached 1. Thus 26221 is a happy number.

For a number to be lucky, it must avoid a savage cull. I wrote about lucky numbers in an eponymously titled post on December 4th 2016. I've also written about them in The Goldbach Conjecture and Lucky Numbers on November 26th 2019 and Generating Lucky Numbers in Python on June 15th 2018. The cull of the natural numbers involves deleting every second number (thus all even numbers disappear), then every third number, then every fourth number and so on. If a happy number turns out to be lucky as well, then it qualifies as a happy go lucky number.

26221 is the 409th happy go lucky number and so the density of such numbers is about 1.56%. In the millennium from 26000 to 27000, Figure 1 shows the only such numbers:


Figure 1

This represents a frequency of 1.4% which is close to the earliest quoted figure of 1.56%. However, after reading this Scientific American article, I discovered that there is no asymptotic density for the happy numbers. To quote from the article: 
... the lower density of the happy numbers is below 12 percent and the upper density is above 18 percent. The fact that happy numbers do not have a defined asymptotic density means there are parts of the number line that have more happiness concentrated in them than others.
The lucky numbers however, do have an asymptotic density which is the same as that of the prime numbers, namely:$$\frac{1}{\log{n}}$$So do the happy go lucky numbers have an asymptotic density? It would appear not because they will have an upper and lower density just as the happy numbers do, so density ranges from:$$ \frac{12}{\log{n}} \rightarrow \frac{18}{\log{n}} $$ So when \(n=26221\), the density range is from \(1.18 \%\) to \(1.77 \% \) with an average of \(1.48 \%\) which is around what we found earlier. The paper in which Justin Gilmer proves his result can be found here.

Tuesday, 26 June 2018

Happy Numbers

Today I turned 25286 days old and 25286 happens to be a happy number, defined as:
Let us define a function \( s(n) \), for \( n>0 \), which gives the sum of the squares of the digits of \( n \), so, for example, \( s(37)=3^2+7^2=58 \).

If we start from a number \(n\)  and we repeatedly apply \( s(\cdot) \), we obtain a sequence \(S_n\) of numbers \(n\), \(s(n) \), \(s(s(n)\), \(\dots \), and so on.

A number \(n\) is called happy if \(S_n \) contains the number 1.

Note that \(s(1)=1 \), so in that case the sequence \( S_n \) has an infinite tail of \(1\)'s.

If a number is not happy then it is easy to see that at a certain point \(S_n\) will enter the infinite loop$$ \dots,4, 16, 37, 58, 89, 145, 42, 20, 4,\dots $$So, for example, starting from  \(94\)  we obtain \(94\rightarrow97\rightarrow130\rightarrow10\rightarrow1\), so \(94\) is happy. 

On the contrary, starting from 61 we obtain \(61\rightarrow37\rightarrow58\rightarrow89 \) and thus 61 is not happy, since 89 belongs to the unhappy loop.

According to Wikipedia: 
by inspection of the first million or so happy numbers, it appears they have a natural density of around 0.15. Perhaps surprisingly, then, the happy numbers do not have an asymptotic density. The upper density of the happy numbers is greater than 0.18577, and the lower density is less than 0.1138. After 25286, the next happy number is 25294 (followed by 25295).
As usual I tried to write some SAGE code to determine whether a number was happy or not. Here is what I came up with:
INPUT (using a happy number 25286):
entered_number=25286
number=str(entered_number)
while sum!= 1 and sum!=4:
    sum=0
    for x in range(len(number)):
        sum+=Integer(number[x])^2
    number=str(sum)
    print(sum) 
OUTPUT
133
19
82
68
100
1
INPUT (using an unhappy number 89)
entered_number=89
number=str(entered_number)
while sum!= 1 and sum!=4:
    sum=0
    for x in range(len(number)):
        sum+=Integer(number[x])^2
    number=str(sum)
    print(sum) 
OUTPUT
145
42
20
4
The 4 is used to prevent the program going into an infinite loop and, at the same time, to mark a number as happy. Unhappy numbers will always enter the following loop:

... 4, 16, 37, 58, 89, 145, 42, 20, 4, ...

Any of the above numbers could be used to identify an unhappy number and break the loop.

The Wikipedia article on unhappy numbers includes the following Python code for determining whether a number is happy or unhappy (rather than displaying the trajectory as I did in my SAGE program):
INPUT (using happy number 25286)
def square(x):
    return int(x) * int(x)
def happy(number):
    return sum(map(square, list(str(number))))
def is_happy(number):
    seen_numbers = set()
    while number > 1 and (number not in seen_numbers):
        seen_numbers.add(number)
        number = happy(number)
    return number == 1
is_happy(25286) 
OUTPUT
True
INPUT (using unhappy number 89)
def square(x):
    return int(x) * int(x)
def happy(number):
    return sum(map(square, list(str(number))))
def is_happy(number):
    seen_numbers = set()
    while number > 1 and (number not in seen_numbers):
        seen_numbers.add(number)
        number = happy(number)
    return number == 1
is_happy(89) 
OUTPUT
False 
As can be seen, the Python code involves a quite different approach. It defines three functions, the second building on the first and the third building on the second : square(x), happy(number) and is_happy(number).

The command sum(map(square, list(str(number)))) caught my eye. This is a very useful command that takes two inputs:
  • a function (in this case, square)
  • a list (in this case, str(number))
It outputs a list (in this case, the sum of the number's digits squared).