1.
Introduction
Let b≥2 and n≥1 be integers. We call n a palindrome in base b (or b-adic palindrome) if the b-adic expansion of n=(akak−1⋯a0)b with ak≠0 has the symmetric property ak−i=ai for 0≤i≤k. As usual, if we write a number without specifying the base, then it is always in base 10, and if we write n=(akak−1⋯a0)b, then it means that n=∑ki=0aibi, ak≠0, and 0≤ai<b for all i=0,1,…,k. So, for example, 9=(1001)2=(100)3 is a palindrome in bases 2 and 10 but not in base 3.
For a long time ago, palindromes were considered only as a part of recreational mathematics, but in recent years, there has been an increasing interest in the importance of palindromes in mathematics [1,2,3,16,25], theoretical computer science [4,15,17,18], and theoretical physics [5,13,21]. For example, in 2016, Banks [6] showed that every positive integer can be written as the sum of at most 49 palindromes in base 10. Two years later Cilleruelo, Luca, and Baxter [11] improved it by showing that if b≥5 is fixed, then every positive integer is the sum of at most three b-adic palindromes. Then Rajasekaran, Shallit, and Smith [31] completed the study by proving that the theorem of Cilleruelo, Luca, and Baxter [11] also holds when b∈{3,4}, and if b=2, then we need four summands to write every positive integer as a sum of b-adic palindromes. Nevertheless, we still have many other interesting open problems concerning palindromes. In particular, on Mathematics Stack Exchange, Vepir asked: which number base contains the most palindromic numbers?
Pongsriiam and Subwattanachai [30] started the investigation by deriving an exact formula for the number of b-adic palindromes not exceeding n, denoted by Ab(n), but the formula is difficult to analyze, and so it does not give an answer to Vepir's question. Then Phunphayap and Pongsriiam [28] calculated the reciprocal sum of all b-adic palindromes implying that if b>b1 and if we use the logarithmic measure, then there are more b-adic palindromes than b1-adic palindromes. Nevertheless, this does not answer Vepir's question according to the counting measure.
In this article, we obtain extremal orders of Ab(n) and show that Ab(n)−Ab1(n) has infinitely many sign changes. We also obtain other related results and use them to solve Vepir's problem.
For more information on the palindromes, we refer the reader to Banks, Hart, and Sakata [7] and Banks and Shparlinski [8] for some multiplicative properties of palindromes, Bašić [9,10], Di Scala and Sombra [14], Goins [19], Luca and Togbé [26] for the study of palindromes in different bases, Cilleruelo, Luca, and Tesoro [12] for palindromes in linear recurrence sequences, Harminc and Soták [20] for b-adic palindromes in arithmetic progressions, Korec [23] for nonpalindromic numbers having palindromic squares, and Pongsriiam [29] for the longest arithmetic progressions of palindromes.
2.
Preliminaries and lemmas
In this section, we provide some definitions and lemmas which are needed in the proof of the main theorems. Recall that for a real number x, ⌊x⌋ is the largest integer less than or equal to x, ⌈x⌉ is the smallest integer greater than or equal to x, and {x} is the fractional part of x given by {x}=x−⌊x⌋. Furthermore, for a mathematical statement P, the Iverson notation [P] is defined by
In the proof of our main results, we often use Pongsriiam and Subwattanachai's formula [30]. So it is convenient to define Cb(n) as follows.
Definition 1. Let b≥2 and n≥1 be integers, and n=(akak−1⋯a1a0)b. Define Cb(n)=(ckck−1⋯c1c0)b to be the b-adic palindrome satisfying ci=ai for k−⌊k/2⌋≤i≤k. In other words, Cb(n) is the b-adic palindrome having k+1 digits, the first half of which are the same as those of n in its b-adic expansion, that is, Cb(n)=(akak−1⋯ak−⌊k2⌋⋯ak−1ak)b.
Example 2. If m=(247853)9 and n=(1327021)8, then C9(m)=(247742)9 and C8(n)=(1327231)8.
Note that our definition of Cb(n) is slightly different from that in Pongsriiam and Subwattanachai's formula [30]. In addition, while we focus only on positive integers, they [30] also count zero. After a slight modification, their formula is as follows.
Lemma 3 (Pongsriiam and Subwattanachai [30]). Let b≥2 and n≥1 be integers, and n=(akak−1⋯a1a0)b. Then the number of b-adic palindromes less than or equal to n is given by
where [n≥Cb(n)] is the Iverson notation.
The next lemma gives an upper bound for Ab(n). By Theorem 9, we will see later that the inequality in Lemma 4 is sharp.
Lemma 4. Let b≥2 and n≥1 be integers. Then
Proof. We write n=(akak−1⋯a1a0)b and let
We see that y≤n, y=bkz, and 1≤z≤(b−1)∑∞i=0b−i=b. By Lemma 3, we obtain
Therefore,
We divide the consideration into two cases according to the parity of k.
Case 1. k is even. Then
Since the function x↦√x+1√x is increasing on [1,∞] and 1≤z≤b, we have
Case 2. k is odd. This case is similar to Case 1. We have
Since 1≤z≤b, we obtain 1≤b/z≤b and therefore
In any case, we obtain the desired result.
Recall that a sequence (xn)n≥1 of real numbers is said to be uniformly distributed modulo 1 if for any 0≤a<b≤1,
A well-known criterion for uniform distribution modulo 1 is as follows [24,page 7].
Lemma 5. (Weyl's Criterion) The sequence (xn)n≥1 is uniformly distributed modulo 1 if and only if
Lemma 6. Let (xn)n≥1 be an arithmetic progression of real numbers, d the common difference, d∈Z∖{0}, and α∈R an irrational number. Then (αxn)n≥1 is uniformly distributed modulo 1.
Proof. Since α is irrational, d≠0, and d∈Z, we have |e2πihαd−1|≠0 for all integers h≠0. Recall that xn=x1+(n−1)d for all n≥1. So if h is a nonzero integer, then
which converges to 0 as N→∞. By Weyl's criterion, the desired result is verified.
The next result is an important tool for obtaining Theorem 11.
Lemma 7. Let (xn)n≥1, d≥1, and α satisfy the same assumption as in Lemma 6, xn∈Z for every n, and let c∈(0,1). Then there are infinitely many integers k≥1 such that
Proof. Suppose for a contradiction that there is only a finite number of integers k≥1 such that xk satisfies (2.1). Let k be the largest such an integer if it exists and let k=1 otherwise. Since d≥1, we see that (xn)n≥1 is strictly increasing, and so if n>k, then xn does not satisfy (2.1). We will get a contradiction by constructing an integer x=xn satisfying (2.1) and n>k. By Lemma 6, (αxn)n≥1 is uniformly distributed modulo 1. From this point on, we apply the above fact repeatedly without reference. Let k1,k2,…,kd be integers satisfying
Then ⌊αxki⌋≡1 (mod 2) for all i=1,2,…,d. We divide the consideration into two cases.
Case 1. d is even. Let kd+1 be an integer such that
Case 1.1 ⌊αxkd+1⌋≡1 (mod 2). We see that
This implies that
Let A=∑d+1i=1xki. Then we have
Since A>xk and A≡x1 (mod d), we see that A=xn for some n>k. But by (2.3), A=xn satisfies (2.1), contradicting the fact that k is the largest integer such that xk satisfies (2.1).
Case 1.2 ⌊αxkd+1⌋≡0 (mod 2). Let M be the maximum value of {αxki} for i=1,2,…,d. Since d is even, we must have d≥2. Then
Therefore there are infinitely many t∈N such that
Then one of the two sets
is infinite, say Y. Then we can choose integers td>td−1>⋯>t1>k in Y so that
and
(If X is infinite, then we can choose such t1,t2,…,td∈X too.) Let
Then
By (2.2) and (2.5), we obtain
which implies that
Similar to Case 1.1, we have
Therefore B=xn for some n>k and xn satisfies (2.1), a contradiction.
Case 2. d is odd. Let kd+1 be an integer satisfying
This case is similar to Case 1. Let D=∑d+1i=1xki. Then D>xk, D≡x1 (mod d), and
Since kd+1>k and {αxkd+1}<c, we see that ⌊αxkd+1⌋≡1 (mod 2). In addition, we have
From (2.6), (2.7), and (2.8), we obtain
Therefore D=xn for some n>k and xn satisfies (2.1), a contradiction.
In any case, we have a contradiction. So the proof is complete.
Lemma 8. Suppose a and b are positive rational numbers and a,b≠1. Then logba is rational if and only if there exist integers m and n such that am=bn.
Proof. This is well-known. For more details, see for example, pages 24–25, Chapter 2 in the book of Niven [27].
3.
Main results
We are now ready to prove our main theorems. We begin with maximal and minimal orders of Ab(n).
Theorem 9. Let b≥2 be an integer. Then
In particular, a maximal order of Ab(n) is (√b+1√b)√n.
Proof. Let ε>0. By Lemma 4, it remains to show that Ab(n)/√n≥√b+1√b−ε for infinitely many n∈N. To prove this, we construct a strictly increasing sequence (nk)k≥1 of positive integers such that
For each k∈N, let nk=b2k+1+1. By Lemma 3, we obtain that Ab(nk)=bk+1+bk−1. Therefore,
as desired.
Theorem 10. Let b≥2 be an integer. Then
In particular, a minimal order of Ab(n) is 2√n.
Proof. Let ε>0. We first show that Ab(n)/√n≥2−ε for all large n. Let N be a large positive integer to be determined later and let n≥bN. Since [bN,∞)=⋃∞k=N[bk,bk+1), we see that bk≤n<bk+1 for some k≥N. Then the number of digits of n in its b-adic expansion is k+1. Let
So y=(akak−1⋯ak−⌊k2⌋00⋯0)b, n≥y, and Ab(n)≥Ab(y). We divide the calculation into two cases according to the parity of k.
Case 1. k is even. Then by Lemma 3,
Observe that
Then √n≤bk/2√z+δ, where δ=b−k/2−b−k>0. Therefore
As N→∞, we see that n→∞, k→∞, and δ/√z+δ≤√δ=√b−k2−b−k→0. Therefore we can choose N large enough so that
Case 2. k is odd. Some calculations in this part are similar to those in Case 1, so we skip some details. Let δ=b−(k−1)/2−b−k>0. By Lemma 3,
In addition,
In any case, we see that if N is large and n≥bN, then Ab(n)/√n≥2−ε. So it remains to show that Ab(n)/√n≤2+ε for infinitely many n∈N. For each k∈N, let n=nk=b2k−2. Then n=(a2k−1a2k−2⋯a1a0)b where a0=b−2 and ai=b−1 for all i=1,2,⋯,2k−1, and n<b2k−1=Cb(n). By Lemma 3, we have
This implies
Since k is arbitrary, there are infinitely many n∈N such that Ab(n)/√n≤2+ε. This completes the proof.
We used a computer to compare the values of Ab(n) when b=2,3,5,10 and n=10k for k=1,2,…,20. The data are shown in Table 1 at the end of this article. We see that for distinct b,b1∈{2,3,5,10}, there is an integer n≥1 such that Ab(n)>Ab1(n) and there is an integer m≥1 such that Ab(m)<Ab1(m). For example, A2(1020)>A10(1020) while A2(1019)<A10(1019). In general, we have the following theorem, which is the main result of this paper.
Theorem 11. Let b>b1≥2 be integers. Then Ab(n)−Ab1(n) has infinitely many sign changes as n→∞. More precisely, the following statements hold.
(i) There are infinitely many n∈N such that Ab1(n)>Ab(n).
(ii) There are infinitely many n∈N such that Ab(n)>Ab1(n).
Proof. Throughout the proof, we apply Lemma 3 repeatedly without reference and separate the proof into two parts. In the first part, we show that (i) holds.
Case 1(i). b is not a rational power of b1. By Lemma 8, we see that logbb1 is irrational. Applying Lemma 7 to the sequence of odd positive integers (1,3,5,7,…) with d=2, α=logbb1, and c=logb(1+1b2), we obtain that there are infinitely many integers k such that
Let k be one of those integers. Since k≡1 (mod 2) and bk1<bk1+1=Cb1(bk1), we obtain
Next, we write bk1=(arar−1⋯a1a0)b. Since br≤arbr≤bk1<br+1, we see that r is the largest integer such that br≤bk1. Therefore r=⌊klogbb1⌋≥⌊5logb1b⋅logbb1⌋=5. In addition, arbr≤bk1<(ar+1)br, so ar is the largest integer such that arbr≤bk1. Therefore
Since {klogbb1}<logb(1+1/b2)<logb2, we see that b{klogbb1}<blogb2=2. Thus ⌊b{klogbb1}⌋<2, which implies ar<2. So ar=1. Next, we calculate ar−1. We see that
Since {klogbb1}<logb(1+1/b2)≤logb(1+1/b), we have
We obtain from (3.3) that ar−1<b+1−b=1, which implies ar−1=0. Similarly, we have
This implies ar−2=0. So we have ar=1 and ar−1=ar−2=0, and thus bk1≤br+br−2. Recall that r=⌊klogbb1⌋≡0 (mod 2), r≥5, and br≤bk1. Since br+br−2<br+br−2+b2+1=Cb(br+br−2), we obtain
From this and (3.2), we obtain
Since b>b1≥2 and the function x↦√x+1√x is increasing on [1,∞),
Therefore Ab1(bk1)−Ab(bk1)>0. Since Ab1(bk1)−Ab(bk1)>0 holds for any k satisfying (3.1), we can choose n=bk1 and obtain that Ab1(n)−Ab(n)>0 for infinitely many n, as required.
Case 2(i). b is a rational power of b1. Let bs=bt1 for some s,t∈N with gcd(s,t)=1. Let m∈N and k=2mt+1. Then k is odd. Since bk1+1=Cb1(bk1+1), we obtain
Since bs=bt1 and k=2mt+1, we obtain bk1=b2mt+11=b1⋅b2ms. Therefore bk1+1=(arar−1⋯a0)b where r=2ms, ar=b1, a0=1, and ai=0 for i=1,2,…,r−1. So
From this and (3.5), we obtain Ab1(bk1+1)−Ab(bk1+1)=1. Since m is arbitrary, we can choose k=2mt+1 and n=bk1+1 so that Ab1(n)−Ab(n)>0 for infinitely many n.
Case 1(i) and Case 2(i) give a proof of (i). The proof of (ii) is quite similar to that of (i). So we omit some details. We divide the consideration into two cases.
Case 1(ii). b is not a rational power of b1. Then logb1b is irrational. Similar to Case 1(i), we apply Lemma 7 and let k be an integer such that
Then
We write bk=(arar−1⋯a1a0)b1. Then r=⌊klogb1b⌋≥k≥5 and
which implies ar=1. Similarly,
which implies ar−1=0. Then
which implies ar−2=0. So bk≤br1+br−21<Cb1(br1+br−21). Recall that r=⌊klogb1b⌋≡0 (mod 2) and r≥5. Then
From this and (3.7), we obtain
Since b>b1≥2 and the function x↦√x+1√x is increasing on [1,∞), we have
Therefore Ab(bk)−Ab1(bk)>0. By Lemma 7, there are infinitely many integers k satisfying (3.6). So we can choose n=bk so that Ab(n)−Ab1(n)>0 for infinitely many n.
Case 2(ii). bs=bt1 for some s,t∈N with gcd(s,t)=1. Let m∈N and k=2ms+1. Then k is odd and
Since bs=bt1, we obtain bk=b2ms+1=b2mt1bts1=b{ts}1⋅b2mt+⌊ts⌋1. Since {ts}=js for some j=0,1,…,s−1, we obtain b{ts}1=bjs1. Recall that for any positive integers x and y, x1/y is either an irrational number or an integer. Then b{ts}1=(bj1)1s is either an irrational number or an integer. If b{ts}1 is irrational, then b=bts1=b{ts}1⋅b⌊ts⌋1 is irrational, a contradiction. So b{ts}1∈N and bk=(arar−1⋯a0)b1 where r=2mt+⌊ts⌋, ar=b{ts}1=bjs1, and ai=0 for all i=0,1,…,r−1. Therefore
In addition, bk2=bms+12=bmt+t2s1. Suppose first that ⌊ts⌋ is even. Then
Since b>bjs1≥1 and the function x↦√x+1√x is strictly increasing on [1,∞), we obtain from (3.9) and (3.10) that
Suppose ⌊ts⌋ is odd. Then similar to (3.10), we obtain
where ℓ=1−{ts}. From this and (3.9), we obtain
Since m is arbitrary, we can choose k=2ms+1 and n=bk so that Ab(n)−Ab1(n)>0 for infinitely many n.
Case 1(ii) and Case 2(ii) give a proof of (ii). Therefore the proof of this theorem is complete.
Observing the proof of Theorem 11 carefully, we can state some parts of Theorem 11 in a stronger form as follows.
Theorem 12. Let b>b1≥2 be integers. Then the following statements hold.
(i) There are infinitely many k∈N and a constant c>0 depending at most on b and b1 and not on k such that
Consequently, lim supn→∞(Ab(n)−Ab1(n))=+∞.
(ii) Suppose b is not a rational power of b1. Then there are infinitely many k∈N and a constant d>0 which depends at most on b and b1 and not on k such that
Consequently, lim infn→∞(Ab(n)−Ab1(n))=−∞
Proof. For (i), we consider Case 1(ii) and Case 2(ii) in the proof of Theorem 11. In Case 1(ii), we see from (3.8) that we can take c=√b+1√b−2−1b21 so that Ab(bk)−Ab1(bk)≥cbk2. Next, we consider (3.11) and (3.12) in Case 2(ii). Let 0<α<1. Since b1>bα1≥1 and the function x↦√x+1√x is increasing on [1,∞), we obtain
Setting α=js in (3.11) and let α=ℓ in (3.12), we see that we can take
so that
If we would like to obtain c that works in (3.8), (3.11), and (3.12), then we can choose
This proves (i). For (ii), we consider (3.4) in Case 1(i), take d=√b1+1√b1−2−1b2, and obtain that
This proves (ii). So the proof is complete.
We are now ready to give a complete answer to Vepir's question [32] posted on Mathematics Stack Exchange. The title of Vepir's post is as follows:
In the comment, Vepir also says that he is only interested in the palindromes having more than one digit. Therefore for each integers b≥2 and n≥1, we let
So fb(n) is the number of b-adic palindromes which have more than one digit and are less than or equal to n. We have the following corollary.
Corollary 13. Let b>b1≥2 be integers. Then fb(n)−fb1(n) changes sign infinitely often as n→∞. In other words, if we use counting measure, then the races between palindromes in any two different bases have infinitely many wins and infinitely many losses.
Proof. By Theorem 11, there are infinitely many n∈N such that Ab1(n)>Ab(n). So if n is such an integer, then
By Theorem 12, there are infinitely many m∈N such that Ab(m)−Ab1(m)≥b. So if m is such an integer, then
This completes the proof.
Corollary 14. Let b>b1≥2 be integers. Then Ab(n)−Ab1(n)=0 for infinitely many n∈N.
Proof. For each n∈N, let g(n)=Ab(n)−Ab1(n). We know that, for any n∈N, both Ab(n+1)−Ab(n) and Ab1(n+1)−Ab1(n) are either 0 or 1. So g(n+1)−g(n) is −1,0, or 1, that is, the difference of any two consecutive terms of the sequence (Ab(n)−Ab1(n))n≥1 is one of −1, 0, or 1. Therefore if Ab(r)−Ab1(r)<0 and Ab(m)−Ab1(m)>0, then there exists an integer n lying between r and m such that Ab(n)−Ab1(n)=0. By Theorem 11, there are infinitely many n∈N such that Ab(n)−Ab1(n)=0, as required.
4.
Conclusion and some future projects
We obtain extremal orders of the palindromes counting function Ab(n) and show that if b>b1≥2, then Ab(n)−Ab1(n) has infinitely many sign changes as n→∞. Moreover, we obtain that
and if b is not a rational power of b1, then
Problem 1. Suppose b>b1 and b is a rational power of b1. Then, perhaps, lim infn→∞(Ab(n)−Ab1(n)) is either −∞ or −1. More precisely, it is −1 if and only if b is an integral power of b1, and it is −∞ if and only if b≠bm1 for any m∈N. We do not have a proof of this yet but we plan to do it in the future.
Problem 2. Suppose b1,b2,…,bk are distinct integers larger than 1. We believe that our results can be extended to the string of inequalities
for infinitely many n∈N. Maybe, if δi∈{0,1,−1} for every i, δ1+δ2+⋯+δk=0, and b1,b2,…,bk satisfy some natural conditions such as logbi/logbj is not rational for any i≠j, then
Problem 3. For positive integers b≥2, n≥1, q≥2, and 1≤a≤q, let Ab(n,q,a) be the number of b-adic palindromes which are less than or equal to n and are congruent to a modulo q. Perhaps, we can find an asymptotic formula for Ab(n,q,a). Then the study of the race between palindromes in different congruence classes (in the same or different bases) may be interesting. For example, under some natural conditions on b and q, are there infinitely many sign changes in Ab(n,q,a1)−Ab(n,q,a2) for distinct a1, a2? If k∈N is fixed, are there b, q, a1, a2 such that the number of sign changes in Ab(n,q,a1)−Ab(n,q,a2) is exactly k?
Problem 4. Can Lemma 7 be extended to any congruence classes? For example, suppose (xn) is an arithmetic progression, xn∈Z for all n∈N, d=x2−x1≥1, α is an irrational number, and 0≤c1<c2≤1. Then for any q≥2 and 0≤a<q, we may be able to prove that there are infinitely many k∈N such that c1<{αxk}<c2 and ⌊αxk⌋≡a(modq). Furthermore, we may be able to replace the assumption that xn∈Z for all n∈N by a weaker condition.
Problem 5. Considering Remark 3.19 in the article by Kawsumarng et al. [22], we see that there exists a palindromic pattern in the sumset B(α2)+B(α2) with respect to the Fibonacci numbers, where B(α2) is the upper Wythoff sequence. It may be interesting to see whether or not these kinds of palindromic patterns occur in the h-fold sumset hB(x) with respect to the members of linear recurrence sequence (an), where x is a particular root of the characteristic polynomial of the sequence (an) and h+1 is the smallest positive integer such that (h+1)B(x) is cofinite.
We plan to solve some of these problems in the future but we do not mind if the readers solve them before us.
Acknowledgments
We are grateful to the editor and reviewers for their comments and suggestions which improve the quality of this article. Prapanpong Pongsriiam's research project is supported jointly by the Faculty of Science Silpakorn University and the National Research Council of Thailand (NRCT), grant number NRCT5-RSA63021-02.
Conflict of interest
The authors declare that there is no conflict of interests regarding the publication of this article.
Appendix