\section{Introduction}



Functions that act on digits of an integer, such as digit sums, are natural to study. In this paper, we look at functions that take in a positive integer and output the sum of its values on the digits of that integer. Precisely, for a fixed base $b$, we start with a function $f_*$ that acts on the digits in base $b$, i.e. $f_*: \{0,1,\dots,b-1\} \to \mathbb{Z}^{\ge 0}$. Then, we extend $f_*$ to a function $f$ on the non-negative integers given by $f(\sum_{i=0}^n a_ib^i) = \sum_{i=0}^n f_*(a_i)$ where $0 \le a_i \le b-1$. 

\vspace{1mm}

In Richard Guy's book ``Unsolved Problems in Number Theory",  Guy poses many questions regarding $(2,10)$-happy numbers. A $(2,10)$-happy number is a number that, under iterates of the digit map $f$ induced by $f_*(m) = m^2$ (in base $10$), eventually reaches $1$ [2]. Happy numbers and their generalizations have been studied recently. An $(e,b)$-happy number is one that ends up at $1$ under iterates of $f$ obtained from $f_*(m) = m^e$. In [1], Pan proved that there exist arbitrarily long sequences of consecutive $(e,b)$-happy numbers assuming that for every prime divisor $p$ of $b-1$, that $p-1$ does not divide $e-1$. As we will show, this is a special case of the assumption stated in the abstract. 

\vspace{1mm}

An important question in Guy's book is that of gaps in the happy number sequence. In this paper, we give an answer to this question by, in particular, showing that there are arbitrarily large gaps in the $(e,b)$ happy number sequence, assuming that for every prime divisor $p$ of $b-1$, that $p-1$ does not divide $e-1$. In fact, we prove something stronger and more general.

We study digit maps, which are of course a generalization of the happy number digit map. It is well-known and easy to see that any positive integer eventually ends up in some finite cycle under digit maps, where here a finite cycle is some collection of positive integers $\{n_1,\dots,n_k\}$ such that $f(n_i) = n_{i+1}$ for $1 \le i \le k-1$ and $f(n_k) = f(n_1)$. For example, the cycles generated by the $(2,10)$-happy number digit map are $\{1\}$ and $\{4,16,37,58,89,145,42,20\}$. A gap in the happy number sequence, therefore, corresponds to consecutive numbers that end up in a cycle different than $\{1\}$. In this paper, a special case of what we prove is that indeed for any $u$ in an $(e,b)$-happy number cycle, we can find arbitrarily long sequences of consecutive integers that end up in the cycle $u$ is in. More interestingly, we show that for \textit{any} digit sequence satisfying the not-so-strict hypotheses in the abstract, and any positive integer in a cycle, we can find arbitrarily long sequences of consecutive positive integers ending up in that cycle. 

Fix a base $b$ and a digit function $f$. We call a positive integer $u$ in some cycle a \textit{cycle number} and any positive integer ending up in that cycle a $u$-\textit{integer}.

\vspace{6mm}







 
\begin{theorem} Fix a base $b$. Suppose $f$ is a digit map such that $f(0) = 0, f(1) = 1, \gcd(b,f(b-1)) = 1$, and there is some digit $0 \le m_* \le b-1 \hspace{1.5mm} \text{s.t.} \hspace{1mm} f(m_*)-m_*$ is relatively prime to $f(b-1)$. Then for any cycle number $u$ and any positive integer $n$, there exist $n$ consecutive $u$-integers.
\end{theorem}

\vspace{3mm}

For example, working in base $10$, if we construct the digit map $f_*: \{0,\dots,9\} \to \mathbb{Z}^{\ge 0}$ given by $f_*(0)=0,f_*(1) = 1$ and $f_*(9) = 7$, then no matter where we send $2,3,4,5,6,7,$ and $8$ we are guaranteed that there will exist arbitrarily long sequences of consecutive positive integers that when we apply $f$ enough times, we will end up at $1$, for example, since $1$ is in a cycle: namely, $\{1\}$. 

\vspace{6mm}









\section{Proof of Theorem 1.1}

We use a few small results in Pan's proof of Theorem 1.1, and introduce new techniques and results in Lemma 2.3 and Corollary 2.2. We omit certain proofs that are nearly identical to those appearing in [1].

\vspace{3mm}

\begin{lemma} Let $x$ and $m$ be arbitrary positive integers. Then for each $r \ge 1$, there exists a positive integer $l$ such that $$f^r(l+y) = f^r(l)+f^r(y) = x+f^r(y)$$ for each $1 \le y \le m$.
\end{lemma}





Let $D$ be the set of all positive integers that are in some cycle, that is $n \in D$ if and only if $f^r(n) = n$ for some $r \ge 1$. It is well known and easy to show that $D$ is finite. 
\vspace{3mm}




\begin{definition} Take some $u \in D$. Then we say a positive integer $n$ is a \textit{$u$-integer} if $f^r(n) = u$ for some $r \ge 1$. Further, we say two positive integers $m,n$ are \textit{concurrently $u$-integers} if for some $r \ge 1$, $f^r(m) = f^r(n) = u$. 
\end{definition}

Thus, two $u$-integers $m,n$ are not concurrently $u$-integers only if $u$ belongs to a cycle (of length greater than $1$) in $D$ and $m,n$ are at different places in the cycle at a certain time. Note ``concurrently $u$-integers'' is a transitive relation. Now fix $u$ and we will prove that there are arbitrarily long sequences of consecutive $u$-integers. 

\vspace{3mm}


\begin{corollary} Assume that there exists $h \in \mathbb{Z}^+$ such that $h+x$ is a $u$-integer for all $x \in D$. Then for arbitrary $m \in \mathbb{Z}^+$, there exists $l \in \mathbb{Z}^+$ such that $l+1,l+2,\dots, l+m$ are $u$-integers. 
\end{corollary}

\vspace{3mm}






\begin{lemma} Assume that for each $x \in D$ there exists $h_x \in \mathbb{Z}^+$ such that $h_x+u$ and $h_x+x$ are concurrently $u$-integers. Then there exists $h \in \mathbb{Z}^+$ such that $h+x$ is a $u$-integer for each $x \in D$.
\end{lemma}

\begin{proof}
We shall prove that under the assumption of Lemma 2.2, for each nonempty subset $X$ of $D$ containing $u$, that there exists $h_X \in \mathbb{Z}^+$ such that $h_X+x$ is a $u$-integer for each $x \in X$.

\vspace{3mm}

The cases $|X| = 1$ and $|X| = 2$ are clear. Assume $|X| > 2$ and the assertion holds for every smaller value of $|X|$. Take some $x \in X$, with $x \not = u$. Then $h_x+u$ and $h_x+x$ are concurrently $u$-integers, so take $r \in \mathbb{Z}^+$ large enough so that $f^r(h_x+u) = f^r(h_x+x) = u$ and $f^r(h_x+y) \in D$ for all $y \in X$. Let $X^* = \{f^r(h_x+y) | y \in X\}$. Then, $X^*$ is clearly a nonempty subset of $D$, $|X^*| < |X|$, and $X^*$ contains $u$. Therefore, by induction hypothesis, there exists $h_{X^*} \in \mathbb{Z}^+$ such that $h_{X^*}+f^r(h_x+y)$ is a $u$-integer for each $y \in X$. By Lemma 2.1, there exists $l \in \mathbb{Z}^+$ satisfying $$f^r(l+h_x+y) = h_{X^*}+f^r(h_x+y)$$ for every $y \in X$. Thus, $h_X = l+h_x$ works.
\end{proof}

\vspace{3mm}






\begin{lemma} Let $h$ be a $u$-integer. Then for every integer $a$, there exists a $u$-integer $l$ such that $l \equiv a \pmod{f(b-1)}$, and such that $l$ and $h$ are concurrently $u$-integers.
\end{lemma}

\begin{proof}
Let $v \in D$ be a $u$-integer such that $h$ and $v$ are concurrently $u$-integers. Let $l_1$ be a $u$-integer. Now we show we can take $l_2$ such that $l_2 \equiv a \pmod{f(b-1)}$ and $f(l_2) = l_1$. 

Note that by multiplying $l_1$ by a power of $b$ satisfying $b^n \equiv 1 \pmod{f(b-1)}$, which we can do since $\gcd(b,f(b-1)) = 1$, we can assume $l_1$ to be large. Now fix $l_1 > f(b-1)f(m_*)$. Since $f(m_*)-m_*$ is relatively prime to $f(b-1)$, we can solve $$l_1-r(f(m_*)-m_*) \equiv a \pmod{f(b-1)}$$ with $0 \le r < f(b-1)$. Note there are infinitely many $j \ge 1$ with $b^j \equiv 1 \pmod{f(b-1)}$. Let $j_1 < j_2 < \dots < j_{l_1-rf(m)} < t_1 < t_2 < \dots < t_r$ satisfy $b^{j_i} \equiv b^{t_i} \equiv 1 \pmod{f(b-1)}$ and $b^{t_{j+1}} > m_*b^{t_j}$. Now let $$l_2 = \sum_{n=1}^{l_1-rf(m_*)} b^{j_n}+m_*b^{t_1}+\dots+m_*b^{t_r}.$$ Note by our choice of $l_1$, the indices of the $j$'s and of the sum are valid. So, $$f(l_2) = l_1-rf(m_*)+rf(m_*) = l_1$$ and $$l_2 \equiv l_1-rf(m_*)+rm_* \equiv a \pmod{f(b-1)},$$ as desired. 

Now we generate $l_3,l_4,\dots$ inductively by choosing $l_{n+1}$ so that $l_{n+1} \equiv a \pmod{f(b-1)}$ and $f(l_{n+1}) = l_n$. Note that since the cycle that $u$ is in is finite, it must be that one of the $l_n$'s is concurrently a $u$-integer with $v$, implying for some $n$, $l_n$ and $h$ are concurrently $u$-integers. \end{proof}

\vspace{3mm}









\begin{corollary} For each $x \in \mathbb{Z}^+$, there is a $u$-integer $l$ such that $l$ and $l+x$ are concurrently $u$-integers.
\end{corollary}

\begin{proof} Fix $x \in \mathbb{Z}^+$. Take $s \in \mathbb{Z}^+$ such that $b^s > x$. Let $x_1 = b^s-x$. Take a $u$-integer $h'$ such that $$h' \equiv f(x_1) \pmod{f(b-1)}.$$ Let $V$ be the cycle set that $u$ is in. By Lemma 2.3, for each $v' \in V$, there exists $l_{v'}$ such that $l_{v'} \equiv 1 \pmod{f(b-1)}$, and $l_{v'}$ and $v'$ are concurrently $u$-integers. Fixing an $l_{v'}$ for each $v' \in V$, let $M = \max_{v' \in V} l_{v'}$.

\vspace{3mm}

Now note that $h'b^{\phi(f(b-1))}$ is also a $u$-integer and since $\gcd(b,f(b-1)) = 1$, $$h'b^{\phi(f(b-1))} \equiv h' \pmod{f(b-1)}.$$ This allows us to choose and fix $h > f(x_1)+M$ to be a $u$-integer with $h \equiv f(x_1) \pmod{f(b-1)}$. Let $v$ be in the cycle of $u$ so that $h$ and $v$ are concurrently $u$-integers. Now take the $u$-integer $N = l_{v}$ so that $N \equiv 1\pmod{f(b-1)}$, and $N$ and $v$ are concurrently $u$-integers. Take a positive integer $t$ so that $b^t > b^{s+\lfloor \frac{h}{f(b-1)}\rfloor+1}$. Let $x_2 = x_1+b^t\sum_{j=1}^{N-1} b^j$. Note $f(x_2) = f(x_1)+(N-1)$ since $b^t > b^s > x_1$. Thus, $$f(x_2) \equiv f(x_1) \equiv h \pmod{f(b-1)}.$$ Also note, $f(x_2) = f(x_1)+(N-1) \le f(x_1)+M-1 < h$. Write $h = f(b-1)k+f(x_2)$ and note that we know $k > 0$. Also note $k \le \lfloor \frac{h}{f(b-1)} \rfloor + 1 < t-s$. Let $$l = x_2+\sum_{j=0}^{k-1}(b-1)b^{s+j}.$$

Then, 

\begin{align*}
f(l) &= f\left(x_1+b^t\sum_{j=1}^{N-1} b^j + b^s\sum_{j=0}^{k-1}(b-1)b^j\right) \\
&= f\left(x_1+b^s[b^{t-s}\sum_{j=1}^{N-1} b^j + \sum_{j=0}^{k-1} (b-1)b^j]\right) \\
&= f(x_1)+f(b^{t-s}\sum_{j=1}^{N-1} b^j + \sum_{j=0}^{k-1} (b-1)b^j)
\end{align*}

and since $\sum_{j=0}^{k-1}(b-1)b^j = b^k-1 < b^{t-s}$, $$f(l) = f(x_1)+(N-1)+kf(b-1) = f(x_2)+kf(b-1) = h.$$ Further, $$f(l+x) = f\left(b^s+\sum_{j=0}^{k-1}(b-1)b^{s+j} + b^t\sum_{j=1}^{N-1} b^j\right) = f\left(b^{s+k}+b^t\sum_{j=1}^{N-1} b^j\right)$$ which is equal to $N$. Since $h$ and $N$ are concurrently $u$-integers, it follows that $l$ and $l+x$ are concurrently $u$-integers, as desired.
\end{proof}

\vspace{3mm}

Theorem 1.1 now follows from Corollary 2.1, Lemma 2.2, and Corollary 2.2.

\vspace{3mm}

Now we show in the generalized happy number setup, the assumption in Theorem 1.1 is satisfied (clearly $f(0) = 0, f(1) = 1$, and $\gcd(b,f(b-1)) = 1$). Write $b-1 = p_1^{\alpha_1}\dots p_k^{\alpha_k}$. For all $i$, let $g_i$ satisfy $(\frac{b-1}{p_i^{\alpha_i}}g_i)^e \not \equiv \frac{b-1}{p_i^{\alpha_i}}g_i \pmod{p_i}$ - any generator of $U(p_i)$ times $(\frac{b-1}{p_i^{\alpha_i}})^{-1} \pmod{p_i}$ will do. Then let $g = \sum_i \frac{b-1}{p_i^{\alpha_i}}g_i$ so that $g \equiv \frac{b-1}{p_i^{\alpha_i}}g_i \pmod{p_i}$ and thus for all $i$, $g^e \equiv (\frac{b-1}{p_i^{\alpha_i}})^eg_i^e \pmod{p_i}$ which is indeed not congruent to $g \pmod{p_i}$ by our choice of $g_i$. Now just reduce $g$ mod $b-1$ so that we get a digit $g$ that satisfies $f(g)-g \not \equiv 0 \pmod{p_i}$ for any $p_i \mid b-1$, and hence $\gcd(f(g)-g,f(b-1)) = \gcd(f(g)-g,(b-1)^e) = 1$.

\vspace{6mm}


\section{Acknowledgement}

I would like to deeply thank Serin Hong for reading this carefully and for providing great feedback. I also thank Professor Tamuz and Akash Parikh. 

\vspace{6mm}

