ON FINDING the SMALLEST HAPPY NUMBERS of ANY HEIGHTS 2 Where B(0) = 0 in Base B
Total Page:16
File Type:pdf, Size:1020Kb
ON FINDING THE SMALLEST HAPPY NUMBERS OF ANY HEIGHTS GABRIEL LAPOINTE Abstract. This paper focuses on finding the smallest happy number for each height in any numerical base. Using the properties of the height, we deduce a recursive relationship between the smallest happy number and the height where the initial height is function of the numerical base. With the usage of the recursive relationship, we build an algorithm that exploits the properties of the height in order to find all of those smallest happy numbers with unknown height. However, with the modular arithmetic, we conclude on an equation that calculates the smallest happy numbers based on known heights for binary and ternary bases. 1. Introduction Researches have been done on smallest happy numbers mainly in decimal base for heights 0 to 12 using the modular arithmetic as shown in theorems 2 to 4 [2] and theorem 3 [6]. Moreover, there is an algorithm that searches for the smallest happy number of an unknown height as shown in [6]. In this paper, we give and describe this algorithm usable for any numerical base B 2. Instead of continuing to search for the smallest happy numbers for any height≥ greater than 12 in decimal base, we are interested on the binary and ternary bases. Small numerical bases may give hints on an equation or an efficient algorithm to obtain the smallest happy number of any height for larger numerical bases. Let x > 0 be an integer. In the numerical base B 2, x can be written as a unique sum ≥ L(x)−1 i x = xiB , (1) i=0 X where the positive integers x0,...,xL(x)−1 are the digits of x and xj = 0 for all j arXiv:1904.12032v2 [math.NT] 7 May 2019 ≥ L(x). We note x as a vector of its digits in base B as being x = (xL(x)−1,...,x0)B where we note L(x) as the length of x and x(k) the kth digit of x starting from the left for k 0, 1,...,L(x) 1 . ∈{ − } Definition 1.1. Let B 2 be the numerical base of a positive integer x. We define ≥ a function HB : N N where −→ L(x)−1 2 B(x)= x , (2) H i i=0 X 2010 Mathematics Subject Classification. Mathematics Subject Classification 2010: 11B37, 11Y55, 11Y16, 11A07. Key words and phrases. Number theory, Smallest happy numbers, Height, Algorithm, Modular arithmetic. 1 ON FINDING THE SMALLEST HAPPY NUMBERS OF ANY HEIGHTS 2 where B(0) = 0 in base B. H n n−1 To simplify the notation, we note B (x)= B (x) B (x) for all n 1, where is the function composition operator.H The identityH is◦H defined as 0 (x≥)= x. ◦ HB Definition 1.2. Let B 2 be the numerical base of a positive integer x. We call x a happy number if and≥ only if there is n N such that n (x)=1. ∈ HB Definition 1.3. We define the height of a happy number x in base B 2 as ≥ ηB : N∗ N where −→ α ηB (x) = min α N : (x)=1 . (3) { ∈ HB } Definition 1.4. We define the smallest happy number in numerical base B 2 ≥ for any height by the function γB : N N∗ where −→ η(x) γB(η(x)) = min x N∗ : (x)=1 . (4) { ∈ HB } To simplify the notation, we will use η = ηB(x) and γ(η) = γB(η). If there is ambiguity, we will precise the numerical base (e.g. γ3(η3)). 2. Smallest happy numbers The objective of this section is to show that there is a relationship between subsequent heights of smallest happy numbers for all base B 2. Then, we get a general equation for γ on which the algorithm will be based. ≥ The following result shows that the function γ is defined uniquely for every η. Theorem 2.1. For all η N, there is a unique x N∗ such that γ(η) = x and ∈ ∈ B(γ(η + 1)) γ(η). H ≥ Proof. To prove the existence, we have to show that there is a x N∗ happy such that η(x) = y. We proceed by induction on y. For y = 0, we have∈ x = 1 such that η(x) = 0 for all B 2. Lets assume that there is a x N∗ happy such that ≥ ∈ η(x) = y. Let z = (1,..., 1)B such that L(z) = x. Thus, B(z) = x and z is also happy. In virtue of the induction hypothesis, η(z) = y +H 1 which proves the existence for all y N. ∈ Let x , x N∗ where x = x . Then, let x > x without loss of generality. 1 2 ∈ 1 6 2 1 2 Having γ(η)= x1 or γ(η)= x2 contradict the definition 1.4. Thus, x1 = x2 which proves the uniqueness. We deduce from the definition 1.4 that B(γ(η + 1)) γ(η). H ≥ We note that 1 is the unique integer of height 0. If 1 <x<B, then B(x) = 2 H x > x. This ensures that (1, 0)B is the smallest happy number of height 1 for all B 2. ≥ Lemma 2.2. If γ(η + 1) B2, then γ(η + 1) >γ(η). ≥ Proof. By theorem 2.1, γ(η + 1) = γ(η) for all η. We proceed by contrapositive and suppose that γ(η) > γ(η + 1).6 Since γ(η + 1) B2, we have, in virtue of the ≥ lemma 6 [1], that B(γ(η + 1)) < γ(η + 1). Applying this with our hypothesis H implies that B(γ(η + 1)) <γ(η) a contradiction with the theorem 2.1. Therefore, γ(η + 1) >γH(η). ON FINDING THE SMALLEST HAPPY NUMBERS OF ANY HEIGHTS 3 We want to show that the smallest happy numbers are strictly increasing as their height increases starting at a certain height when γ(η + 1) > 2(B 1)2. However, even if B2 γ(η + 1) 2(B 1)2, it is generally not true. For− example, using ≤ ≤ − 2 brute-force, we calculate that γ18(28) = (1, 2, 17)18 >B and γ18(29) = (11, 16)18. We see that γ18(28) >γ18(29). The next result ensure that γ(η),γ(η + 1),... is strictly increasing when γ(η + 1) > 2(B 1)2 for all B 3 and{ γ(η + 1) B2}for the binary base. − ≥ ≥ Lemma 2.3. If γ(η + 1) > 2(B 1)2 for all B 3 and γ(η + 1) B2 if B =2, then γ(η) <γ(η + 1) <...<γ(η−+ k) for all k ≥N. ≥ ∈ Proof. Let’s proceed by induction on k. For the base case, we have to show that γ(η) <γ(η + 1). Since γ(η + 1) > 2(B 1)2 B2 for all B 3 and γ(η + 1) B2 if B = 2, we apply the lemma 2.2 and− then≥ get the result.≥ Suppose that γ(≥η) < γ(η + 1) <...<γ(η + k) holds for a certain k. We have to show that it also holds for k + 1. Suppose that γ(η+k+1) 2(B 1)2 for all B 3 and γ(η+k+1) <B2 if B = 2. ≤ − N ≥ n 2 In virtue of the corollary 7 [1], there is n such that B(γ(η + k + 1)) < B . n+1 ∈ 2 H ′ It follows that B (γ(η + k + 1)) 2(B 1) which is maximal if any γ(η ) = H ≤ −′ (B 1,B 1)B for all n < η + k + 1 and η η + k + 1. By induction on n with the− theorem− 2.1, one shows that γ(η′) 2(B ≤1)2 for all η′ η + k +1. Therefore, it is generally false to say that γ(0) <γ≤(1) <...<γ− (η′). ≤ Suppose instead that γ(η+k+1) > 2(B 1)2 for all B 3 and γ(η+k+1) B2 if B = 2. By the lemma 2.2, we have γ(η +−k + 1) >γ(η +≥k). Using the induction≥ hypothesis, we get γ(η) < γ(η + 1) <...<γ(η + k) < γ(η + k + 1). Therefore, γ(η) <γ(η + 1) <...<γ(η + k) for all k N. ∈ Let [x] be the integer part function of x and x be the ceiling function of x. The operator in the expression a b denotes the⌈ concatenation⌉ of a and b. ∗ ∗ Let Lη = αη + tη denotes the total number of digits of γ(η), where αη is the number of digits lower than B 1 and tη the number of B 1. We also note − − γ(η)= Aη Tη where Aη is the integer containing the digits lower than B 1 and ∗ − Tη the digits B 1. The next results give boundaries on αη and tη. − γ(η) Corollary 2.4. We have tη 2 (2B 4) for all B 2. +1 ≥ (B−1) − − ≥ h i γ(η) Proof. Let yη+1 = (B−1)2 . By definition of tη+1, we know that h i αη = Lη tη . (5) +1 +1 − +1 In virtue of the lemma 2.1 [4], yη Lη yη + 4. With the equation (5), +1 ≤ +1 ≤ +1 it implies that αη+1 yη+1 +4 tη+1 and yη+1 αη+1 + tη+1. With γ(η) = 2 ≤ − ≤ (B 1) yη = Aη Tη, we deduce that − +1 ∗ 2 2 2 (B 1) yη (B 2) (yη +4 tη ) + (B 1) tη . (6) − +1 ≤ − +1 − +1 − +1 The inequation (6) is equivalent to 2 (2B 3)yη (4B 16B +16)+(2B 3)tη − +1 ≤ − − +1 4B2−16B+16 1 which gives tη yη = yη 2B +5 .