Showing posts with label happy. Show all posts
Showing posts with label happy. Show all posts

Wednesday, 22 November 2023

Happy Triangular Numbers

I have to confess to treating triangular numbers with some complacency over the years. Let's recall that triangular numbers are of the form:$$ \frac{n \, (n+1)}{2} \text{ with } n \geq 1$$The first triangular numbers are:

1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210, 231, 253, 276, 300, 325, 351, 378, 406, 435, 465, 496, 528, 561, 595, 630, 666, 703, 741, 780, 820, 861, 903, 946, 990, 1035, 1081, 1128, 1176, 1225, 1275, 1326, 1378, 1431


Figure 1: Triangular numbers appear in Pascal's Triangle.
In fact 3rd diagonal of Pascal's Triangle, gives all triangular numbers as shown

Similarly I've grown rather complacent about happy numbers that have the property that repeated iterations of the sum of digits squared lead to 1. For example:$$ 27261 \rightarrow 94, 97, 130, 10, 1$$The reason that I chose 27261 is that it's the number associated with my diurnal age today.

It turns out however, that numbers that are both triangular and happy are rather rare. These types of numbers comprise OEIS A076712 and the initial members of the sequence are:

1, 10, 28, 91, 190, 496, 820, 946, 1128, 1275, 2080, 2211, 2485, 3321, 4278, 8128, 8256, 8778, 9591, 9730, 11476, 12090, 12880, 13203, 13366, 13530, 15753, 16471, 17205, 17578, 20910, 21115, 21321, 22791, 24753, 25651, 27261, 29890, 30135, 31626, 33670, 35245

As can be seen, it will be quite some time before I meet the next such number: 29890. The main reason for creating this post was to draw attention to an interesting website titled Fascinating Triangular Numbers run by Shyam Sunder Gupta. It was begun on October 26th 2002 but remains active. There is a plethora of information on this site about various properties of triangular numbers so it's a wonderful resource.

What follows are just two examples from the site:

Example 1: The only known example of a Pythagorean triangle (\(a, b, c\)) where \(a, b, c\) are triangular numbers is (8778, 10296, 13530): $$ \begin{align} 8778^2 + 10296^2 &= 13530^2 \\ (\text{T}_{132})^2 + (\text{T}_{143})^2 &= (\text{T}_{164})^2 \end{align} $$Example 2: The only known examples of a Pythagorean triangle such that both Perimeter as well as Area are triangular numbers are: $$ \begin{align} &3312, 14091, 14475) \\ \text{with Perimeter } &= 31878 = T_{252} \\ \text{and Area } &= 23334696 = T_{6831}\\  \\&3405996, 8013265, 8707079 \\ \text{with Perimeter } &= 20126340 = T_{6344} \\ \text{and Area } &= 13646574268470 = T_{5224284} \end{align} $$

Tuesday, 29 June 2021

SOD ET AL

SOD stands in a mathematical context for Sum of Digits and it can also be written as SoD or sod. Unlike a number's primeness or non-primeness, a number's SoD is peculiar to the number system being used and is thus of interest mainly in recreational mathematics. My diurnal age today is 26384 with a sum of digits of 23. When these two numbers are added together, the result is a prime number, 26407. This qualifies 26384 for inclusion in OEIS A047791:


 A047791

Numbers \(n\) such that \(n\) plus digit sum of \(n\) (A007953) equals a prime.       


There are 2919 such numbers in the range of numbers from 1 to 26384, constituting about 11.1% of the total number. In the same range, there are 2897 primes and so the totals are nearly identical. This is not surprising because the operation of adding the sum of digits of a number to itself simply changes the number into another number of slightly higher value, without regard to its being prime or composite.


ODDS AND EVENS


Recently, I made a series of posts that involved adding the odd digits to a number and subtracting the even digits. These posts were titled:
I covered a lot of material in those posts so refer to those for more details.


SELF AND JUNCTION NUMBERS

In this post, I want to collect together some of the other mathematical activities that involve the sum of the digits of a number or the manipulation of the digits is some way. Let's start with the concept of a self number. If there does NOT exist a number \(x\) such that \(x\) + sod(\(x\)) = \(n\) for some number \(n\), then \(n\) is said to be a self number. There are 10 self numbers in the range from 26300 to 26400:

26307, 26318, 26320, 26331, 26342, 26353, 26364, 26375, 26386, 26397

Looking at the above numbers, it can be seen that 26308 is not in the list. This is because:

26285 + sod(26285) = 26285 + 23 = 26308

Apart from self numbers, most numbers are like 26385. There is only one value of \(x\) for which \(x\) + sod(\(x\)) = \(n\). If there is more than one value of x then the number is said to be a junction number. In the range from 26300 to 26400, there are nine junction numbers:

26311 is a junction number [26291, 26300]
26313 is a junction number [26292, 26301]
26315 is a junction number [26293, 26302]
26317 is a junction number [26294, 26303]
26319 is a junction number [26295, 26304]
26321 is a junction number [26296, 26305]
26323 is a junction number [26297, 26306]
26325 is a junction number [26298, 26307]
26327 is a junction number [26299, 26308]

Thus we see, using the first number 26311 as an example, that: 
  • 26291 + sod(26291) = 26291 + 20 = 26311 and 
  • 26300 + sod(26300) = 26300 + 11 = 26311
I've written about self and junction numbers in an eponymous post from October 25th 2018. The numbers above give an idea of the relative proportions of such numbers: about 10% are self numbers, 10% are junction numbers and 80% are neither.


HAPPY NUMBERS

Happy numbers don't involve the sum of the digits per se but instead are concerned with the sum of the digits squared. If this process is applied recursively and the end result is 1, then the number is said to be happy. For example, 94 is an example of such a number because:

 94 → 97 → 130 → 10 → 1 

Only about 15% of numbers are happy. The rest end up in a loop (4, 16, 37, 58, 89, 145, 42, 20, 4) and 61 is an example of such a number because:

61 → 37 → 58 → 89 and the loop has been entered

I've written about happy numbers in a series of posts:

SELFIE NUMBERS

I wrote about these sorts of numbers in an eponymous post on March 27th 2020. In it, I quoted the following:
Numbers represented by their own digits by certain operations are considered as selfie numbers. Some times they are called wild narcissistic numbers. There are many ways of representing selfie numbers. They can be represented in digit’s order, reverse order of digits, increasing and/or decreasing order of digits, etc. These can be obtained by use of basis operations along with factorial, squareroot, Fibonacci sequence, Triangular numbers, binomial coefficients, s-gonal values, centered polygonal numbers, etc. In this work, we have written selfie numbers by use of concatenation, along with factorial and square-root. The concatenation idea is used in a very simple way. The work is limited up to 5 digits. Work on higher digits shall be dealt elsewhere. Source.

I use the example of 25926 that can be expressed as: 

((−2+5)!)!×C(9,2)+6 = (3!)! x 36 + 6 = 6! x 36 + 6 = 720 x 36 + 6 = 25926

Another example is \(39304:=((4||03)−9)^3\) where || stands for concatenation.

This is a big topic and it has been covered in detail in my prementioned blog post.


FRIEDMAN NUMBERS

These could be considered a subset of the selfie numbers but they form a category in their own right and are constructed much more simply. I wrote about these in a blog post from October 8th 2020 titled Forming Equations from Integers. To quote:

Consider \(28547=(8+5)^4−(7×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×2])^5\).


NARCISSISTIC NUMBERS 

Selfie numbers are sometimes called wild narcissistic numbers but the proper narcissistic numbers. Numbers Aplenty defines them thus:

A number \(n\)  of \(k\)  digits is called narcissistic if it is equal to the sum of the \(k^{th}\) powers of its digits. For example, \(153\)  is narcissistic because \(153 = 1^3+5^3+3^3\). Narcissistic numbers are also called Armstrong or plus-perfect numbers. It has verified that there in fact only 88 such numbers. Those up to one million are: 1, 2, 3, 4, 5, 6, 7, 8, 9, 153, 370, 371, 407, 1634, 8208, 9474, 54748, 92727, 93084, 548834, 1741725, 4210818, 9800817, 9926315.


D-POWERFUL NUMBERS 

D-powerful numbers are akin to narcissistic numbers but with more flexibility regarding the powers to which the digits may be raised. To quote from Numbers Aplenty:

An integer \(n\) is called digitally powerful (here d-powerful) if it can be expressed as a sum of positive powers of its digits. For example:$$3459872 = 3^1 + 4^6 + 5^5 + 9^6 + 8^3 + 7^7 + 2^{21}$$The first d-powerful numbers are:

1, 2, 3, 4, 5, 6, 7, 8, 9, 24, 43, 63, 89, 132, 135, 153, 175, 209, 224, 226, 262, 264, 267, 283, 332, 333, 334, 357, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 407, 445, 463, 518, 598, 629, 739, 794, 849, 935, 994


HARSHAD AND MORAN NUMBERS 

I've written about Harshad Numbers in the following posts:

In the first of the two posts, I posted from Wikipedia:
In recreational mathematics, a Harshad number (or Niven number) in a given number base, is an integer that is divisible by the sum of its digits when written in that base. Harshad numbers in base n are also known as n-harshad (or n-Niven) numbers. Harshad numbers were defined by D. R. Kaprekar, a mathematician from India. The word "harshad" comes from the Sanskrit harį¹£a (joy) + da (give), meaning joy-giver. The term “Niven number” arose from a paper delivered by Ivan M. Niven at a conference on number theory in 1977. 

They are quite frequent and account for about 12% of all the numbers up to 100,000. Here are the first few:

1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 18, 20, 21, 24, 27, 30, 36, 40, 42, 45, 48, 50, 54, 60, 63, 70, 72, 80, 81, 84, 90, 100, 102, 108, 110, 111, 112, 114, 117, 120, 126, 132, 133, 135, 140, 144, 150, 152, 153, 156, 162, 171, 180, 190, 192, 195, 198, 200, 201, 204

If the dividend happens to be a prime number then the number is said to be a Moran number. To quote from Numbers Aplenty again:

A number \(n\) is a Moran number if \(n\) divided by the sum of its digits gives a prime number. For example, 111 is a Moran number because 111/(1+1+1) = 37 and 37 is a prime number. Moran numbers are a subset of Harshad numbers. 

The first few Moran numbers are: 

18, 21, 27, 42, 45, 63, 84, 111, 114, 117, 133, 152, 153, 156, 171, 190, 195, 198, 201, 207, 209, 222, 228. 


MAGNANIMOUS NUMBERS

I've written about these in an eponymous post December 27th 2020. To quote from Numbers Aplenty, a magnanimous number can be define as:

A number (which we assume of at least 2 digits) such that the sum obtained inserting a "+" among its digit in any position gives a prime.

For example, 4001 is magnanimous because the numbers 4+001=5, 40+01=41 and 400+1=401 are all prime numbers.

Since all the prime numbers are odd, except for 2, all the magnanimous numbers, except for 11, are either a sequence of odd digits followed by an even digit, or a sequence of even digits followed by an odd digits.

It is conjectured that the magnanimous numbers are finite and that probably the largest one is 97393713331910, while the largest one which is also a prime number itself is probably 608844043.

The first such numbers are:

11, 12, 14, 16, 20, 21, 23, 25, 29, 30, 32, 34, 38, 41, 43, 47, 49, 50, 52, 56, 58, 61, 65, 67, 70, 74, 76, 83, 85, 89, 92, 94, 98, 101, 110, 112, 116, 118, 130, 136, 152, 158, 170, 172, 203 


DIGITAL ROOT 

While I've not made a specific post about digital roots, I've nonetheless mentioned them in the following posts:

To quote from Wikipedia:
The digital root (also repeated digital sum) of a natural number in a given radix is the (single digit) value obtained by an iterative process of summing digits, on each iteration using the result from the previous iteration to compute a digit sum. The process continues until a single-digit number is reached. In base 10, this is equivalent to taking the remainder upon division by 9 (except when the digital root is 9, where the remainder upon division by 9 will be 0).

Associated with the digital root is the concept of additive persistence defined as:

The additive persistence counts how many times we must sum its digits to arrive at its digital root. For example, the additive persistence of 2718 in base 10 is 2: first we find that 2 + 7 + 1 + 8 = 18, then that 1 + 8 = 9. 


SMITH AND HOAX NUMBERS 

I mentioned Smith numbers in a blog post dating back to April 21st 2016 and titled Repunits and Smith Numbers. 

Smith numbers are composite numbers with the property that the sum of their digits equals the sum of digits of their prime factors e.g. 22 → 2 + 2 = 4 and 22 = 2 * 11 → 2 + 1 + 1 = 4.

Hoax numbers are similar except they only consider distinct prime factors. Thus, for example, the Smith numbers 4 and 27 are excluded because the sums of their distinct prime factors are 2 and 3 respectively whereas their sums of digits are 4 and 9. The set of hoax numbers is a subset of the set of Smith numbers. 

666 is a Smith number since 666 = 2 * 3 * 3 * 37 and 6 + 6 + 6 = 2 + 3 + 3 + 3 + 7. 

The initial Smith numbers are:

 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438 

The initial hoax numbers are:

22, 58, 84, 85, 94, 136, 160, 166, 202, 234, 250, 265, 274, 308, 319, 336, 346, 355  
 

THE RATS SEQUENCE

I wrote about this in an eponymous post from September 26th 2020. Here is an excerpt:

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.

Sunday, 7 March 2021

Neglected Numbers

Sometimes it's easy to give up on numbers. Take 26271 for example. This number represents my diurnal age today and when I searched in the OEIS nothing of interest showed up. Even a search using OEIS + 26271, which often throws up OEIS b-files containing the number, didn't reveal anything interesting. 

Figure 1: link

In such situations I fall back on the Sequence Database: a database with 2402879 machine generated integer and decimal sequences. I discovered this site in June of 2020. Unfortunately, this didn't turn up any sequences of interest either but then I remembered another site that lists sequences (see Figure 1). 

It was here that I found something of substance. See Figure 2.


Figure 2

26271 belongs to a sequence of numbers \(n\) with the property that \(n\) is 5-almost prime and \(n+1 \) is 6-almost prime. In the case of 26271, it factors to \(3^3 \times 7 \times 139 \) and 26272 factors to \(2^5 \times 821\). The example of 728, the first member of the sequence, is given in Figure 1.

It's easy enough to generate this sequence in SageMath, using the algorithm shown in Figure 3:


Figure 3: permalink

This algorithm can be easily modified to search for other patterns involving \(k\)-almost primes where \(k \geq 2\). For example, what numbers \(n\) are there, up to 26271, with the property that \(n\) is 4-almost prime and \(n+1 \) is 5-almost prime? These numbers turn out to be quite numerous and I won't list them all here but notice how 26270 makes an appearance:

495, 975, 1071, 1287, 1484,  ... , 26075, 26103, 26195, 26215, 26270

From this we can see that 26271 is the middle term in a triplet of numbers with the property that: 
  • \(26270 = 2 \times 5 \times 37 \times 71\) and is 4-almost prime
  • \(26271 = 3^3 \times 7 \times 139 \) and is 5-almost prime
  • \(26272 = 2^5 \times 821\) and is 6-almost prime
This condition could be a good candidate for admission to the OEIS. It could be framed as follows:
Numbers \(n\) such that \(n-1\) is 4-almost prime, \(n\) is 5-almost prime and \(n+1\) is 6-almost prime.
Up to 100,000 the members of this sequence are:
11151, 13455, 23375, 26271, 31311, 33776, 36125, 40375, 45495, 46375, 48411, 49049, 49167, 61335, 63125, 74151, 77895, 78111, 78351, 80271, 82575, 83511, 84591, 86031, 87375, 88749, 90207

I checked and this sequence is not currently in the OEIS so I'll put it forward as a candidate and report back here when it's approved.

Reporting back, I'm happy to report that the sequence was approved, although one of the arbiters took exception to my use of the term \(n\)-almost prime and suggested that it be replaced by composite with \(n\) prime factors. I followed this suggestion (always a good idea to keep the arbiters on side) and the result is OEIS A342246:


 A342246

Numbers \(n\) such that \(n-1\), \(n\) and \(n+1\) are all composite with four, five and six (not necessarily distinct) prime factors respectively

Before I discovered the 5-almost prime and 6-almost prime link on the Italian site, I also made a discovery of my own. 26271 is a member of a sequence of numbers such that the sum of its digits is equal to the sum of the digits of its totient. Here the digits of 26271 add to 18 and the digits of its totient 14904 also add to 18. Up to 26271, about 7.61% of numbers have this property. The members of this sequence, up to 1000, are as follows:

1, 21, 27, 34, 54, 63, 81, 106, 108, 117, 126, 129, 135, 136, 142, 147, 156, 162, 171, 178, 195, 205, 212, 214, 216, 234, 237, 243, 252, 270, 272, 291, 315, 324, 333, 342, 351, 356, 358, 394, 402, 405, 424, 432, 441, 459, 493, 502, 504, 513, 538, 540, 544, 565, 585, 624, 630, 663, 702, 712, 714, 716, 718, 723, 729, 745, 804, 810, 831, 834, 835, 840, 864, 873, 918, 932, 934, 936, 943, 981

This discovery also prompted me to investigate the sum of the digits of the sum of the divisors. The percentage of numbers whose sum of digits equals the sum of the digits of the sum of its divisors is 4.59%. The members of this sequence, up to 1000, are as follows:

1, 15, 24, 64, 69, 78, 90, 114, 133, 147, 153, 186, 198, 258, 270, 276, 288, 306, 339, 360, 366, 393, 429, 474, 492, 495, 507, 522, 582, 588, 609, 618, 627, 639, 708, 717, 738, 762, 763, 801, 817, 834, 846, 871, 906, 933, 960, 978, 990

The percentage of numbers whose sum of digits equals both the sum of the digits of the sum of its divisors AND the sum of the digits of its totient is 0.727%. The members of this sequence, up to 10000, are as follows:

1, 147, 270, 834, 1158, 1374, 1377, 2028, 2214, 2436, 2454, 2538, 2592, 2646, 2754, 2862, 2907, 3339, 3726, 4293, 4320, 4371, 4614, 5049, 5262, 5319, 5472, 5508, 5607, 5670, 5751, 5802, 6234, 6291, 6426, 6570, 6972, 7155, 7209, 7434, 7560, 7605, 7614, 8190, 8934, 9126, 9270, 9315, 9333, 9342, 9720, 9744, 9810

This last sequence might be an interesting one for admission to the OEIS (as it's not currently in there) but I'll wait until my current submission is approved. This is again easy to generate in SageMath as Figure 4 shows:


Figure 4: permalink

In conclusion, it can be said that 26271 is an Ulam number, being the sum of two previous Ulam numbers, namely 47 and 26224. It is also a happy number since repeated sums of squares of digits lead to 1. However, as we've seen, it also has other interesting properties that a little research uncovered.

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.