\documentclass[12pt,reqno]{article} \usepackage[usenames]{color} \usepackage{amssymb} \usepackage{graphicx} \usepackage{amscd} \usepackage[colorlinks=true, linkcolor=webgreen, filecolor=webbrown, citecolor=webgreen]{hyperref} \definecolor{webgreen}{rgb}{0,.5,0} \definecolor{webbrown}{rgb}{.6,0,0} \usepackage{color} \usepackage{fullpage} \usepackage{float} \usepackage{psfig} \usepackage{graphics,amsmath,amssymb} \usepackage{amsthm} \usepackage{amsfonts} \usepackage{latexsym} \usepackage{epsf} \setlength{\textwidth}{6.5in} \setlength{\oddsidemargin}{.1in} \setlength{\evensidemargin}{.1in} \setlength{\topmargin}{-.1in} \setlength{\textheight}{8.4in} \newcommand{\seqnum}[1]{\href{http://oeis.org/#1}{\underline{#1}}} \begin{document} \begin{center} \epsfxsize=4in \leavevmode\epsffile{logo129.eps} \end{center} \theoremstyle{plain} \newtheorem{theorem}{Theorem} \newtheorem{corollary}[theorem]{Corollary} \newtheorem{lemma}[theorem]{Lemma} \newtheorem{proposition}[theorem]{Proposition} \theoremstyle{definition} \newtheorem{definition}[theorem]{Definition} \newtheorem{example}[theorem]{Example} \newtheorem{conjecture}[theorem]{Conjecture} \newtheorem{notation}[theorem]{Notation} \theoremstyle{remark} \newtheorem{remark}[theorem]{Remark} \newtheorem{note}[theorem]{Note} \newtheorem{observation}[theorem]{Observation} \begin{center} \vskip 1cm{\LARGE\bf A Generalization of Collatz Functions and Jacobsthal Numbers \\ } \vskip 1cm \large Ji Young Choi\\ Department of Mathematics\\ Shippensburg University of Pennsylvania\\ 1871 Old Main Drive\\ Shippensburg, PA 17257 \\ USA\\ \href{mailto:jychoi@ship.edu}{\tt jychoi@ship.edu} \\ \end{center} \vskip .2 in \begin{abstract} Let $b \geq 2$ be an integer and $g=b-1$. We consider a generalization of the modified Collatz function: for any positive integer $m$, the $g$-Collatz function $f_g$ divides $m$ by $g$, if $m$ is a multiple of $g$; otherwise, the $g$-Collatz function $f_g$ is the least integer greater than or equal to $\frac {bm} g$. Using this $g$-Collatz function, we extend the Collatz problem, and we show that there are nontrivial cycles for some $g$. Then we show how the function $f_g$ transforms the base-$b$ representation of positive integers, and we study the sequence of the $b$-ary representation of integers generated by the function $f_g$, starting with a $b$-ary string representing $b^N$ for an arbitrary large integer $N$. We show each $b$-ary string in the sequence has a repeating string, and the number of occurrences of each digit in each shortest repeating string generalizes Jacobsthal numbers. \end{abstract} \section{Introduction} \def\modd#1 #2{#1\ \mbox{\rm (mod}\ #2\mbox{\rm )}} \begin{definition}\cite{Col, Riho}\label{D:modi} For any positive integer $m$, the \textit{Collatz function} $f_1$ and the \textit{modified Collatz function} $f_2$ on $m$ are defined as follows: \begin{equation}\label{E:collatz} f_1(m):= \begin{cases} \frac m 2, &\text{if $m$ is even;}\\ 3m+1, &\text{if $m$ is odd,} \end{cases} \text{ and } f_2(m):=\begin{cases} \frac m 2, &\text{if $m$ is even;}\\ \frac {3 m+1} 2=\lceil\frac{3m}2\rceil, &\text{if $m$ is odd.} \end{cases} \end{equation} \end{definition} Collatz \cite{Col} asked if every positive integer $m$ is mapped to $1$ by applying the Collatz function or the modified Collatz function repeatedly: $f_i^n(m)=1$ for some integer $n$, where $i=1$ or $2$. Conway \cite{Con} proved that a generalization of the Collatz problem is undecidable, and there are several ways to generalize the Collatz function. For example, Conway considered the following: \begin{equation}\label{E:Conway} \bar{f}(m)=a_im+b_i, m\equiv \modd i p, \end{equation} where $a_i$ and $b_i$ are rational numbers so that $\bar{f}(m)$ is an integer. Notice that the Collatz function (\ref{E:collatz}) is the same as (\ref{E:Conway}), when $p=2$, $a_0=\frac 1 2$, $b_0=0$, $a_1=3$, and $b_1=1$. Throughout this paper, we let $g$ be an integer greater than $1$ and $b=g+1$ (unless we specify otherwise), and we consider $p=g$, $a_0=\frac 1 g$, $b_0=0$, $a_i=b$, $b_i=g-i$ for (\ref{E:Conway}), as follows: \begin{equation}\label{E:Collatz function} \bar{f}_g(m):= \begin{cases} \frac m g, &\text{if $m\equiv \modd 0 g$;}\\ bm+g-i, &\text{if $m\equiv \modd i g$ for $i= 1, 2, \ldots, g-1$.} \end{cases} \end{equation} Then, as we modified $f_1$ to $f_2$, we modify $\bar{f}_g$ as shown in the following definition, by considering $\bar{f}_g(m)$, if $g$ divides $m$; $\bar{f}_g^2(m)$, otherwise. \begin{definition}\label{D:g Collatz} For any integer $g\geq 2$ and any positive integer $m$, the $g$-\textit{Collatz function} $f_g$ on $m$ is defined as follows: \begin{equation}\label{E:gen collatz} f_g(m):= \begin{cases} \frac m g, &\text{if $m\equiv \modd 0 g$;}\\ \frac{bm+g-i}{g}=\lceil\frac {bm}g\rceil, &\text{if $m\equiv \modd i g$ for $i= 1, 2, \ldots, g-1$.} \end{cases} \end{equation} \end{definition} Now we extend the Collatz problem. We ask if every positive integer $m$ is eventually mapped to $1$ by repeatedly applying the $g$-Collatz function: if $f_g^n(m)=1$ for some integer $n$, and we call it the \emph{$g$-Collatz problem}. We can answer this $g$-Collatz problem immediately for some $g$ by finding a nontrivial cycle. For example, when $g=3$, we can find a nontrivial cycle in $$ 5\rightarrow 7\rightarrow 10 \rightarrow 14\rightarrow 19\rightarrow 26 \rightarrow 35 \rightarrow 47\rightarrow 63\rightarrow 21 \rightarrow 7\rightarrow \cdots. $$ Table \ref{Table:gmk} shows the minimum positive integer $m$ such that $f_g^n(m)\neq 1$ for every $n$ and the minimum integer $k>g$ such that $f_g^n(k)=k$ for some $n$, where $g=3, 4, \dots, 20$. \begin{table}[ht] \begin{center} \begin{tabular}{|r|cccccccccccccccccc|} \hline $g$ &$3$&$4$ & $5$ & $6$ &$7$& $8$&$9$& $10$&$11$&$12$&$13$&$14$&$15$&$16$&$17$&$18$&$19$&$20$\\ \hline $m$ &$5$&$11$ & & $7$& & & $31$& $34$& $588$& $767$ & & &$49$ &$35$ &$19$&&&$63$\\ \hline $k$ &$7$&$23$ & & $23$& & & $35$& $42$& $642$& $1348$ & & &$53$ &$178$ &$79$&&&$71$\\ \hline \end{tabular} \end{center} \caption{Minimum $m$ and $k>g$: $m\not\rightarrow 1$ and $k\rightarrow k$ by $f_g$ repeatedly} \label{Table:gmk} \end{table} When $g=5, 7, 8, 13, 14, 18$, and $19$, every positive integer up to $2\times 10^9$ is mapped to $1$ by $f_g^n$ for some $n$, but we do not know whether every integer beyond $2\times 10^9$ also reaches $1$. The $g$-Collatz problem for $g=5, 7, 8, 13, 14, 18$, and $19$ seems hard, just as in the original Collatz problem. Do we know which values of $g$ provide a nontrivial cycle for the corresponding $g$-Collatz problem? That is, can we find a pattern for $g$ which makes the $g$-Collatz problem different from the original Collatz problem? If we can answer this question, we can solve the original Collatz problem, since the original Collatz problem is the $2$-Collatz problem. Hence, we want to work on a different property of the Collatz function to see if the property can be extended for all $g$. The number of occurrences of each digit in each shortest repeating string in the ternary Collatz sequence starting with $3^N$ for an arbitrary large $N$ is expressed with Jacobsthal numbers \cite{Choi}. We wonder if we can extend this. That is, we want to know if we can generalize Jacobsthal numbers, to express the number of occurrences of each digit in each shortest repeating string in the $b$-ary $g$-Collatz sequence starting with $b^N$ for an arbitrary large $N$, for all $g$. It is easy to do for some $g$, but not easy for all $g$. In this paper, we provide two different generalizations of Jacobsthal numbers: one is defined for $g\not\equiv\modd 2 4$ and the other for $g\equiv\modd 2 8$, except $g=2$. For $g\equiv\modd 6 8$, we may need to consider infinitely many cases, and we could provide infinitely many new types of generalizations of Jacobsthal numbers. This is desirable for future work. Section \ref{S:notation} clarifies the notation in this paper. Section \ref{S:modifed} shows how to apply the $g$-Collatz function to the base-$b$ representation of positive integers. In Section \ref{S:sequence}, we study the shortest repeating string in the sequence of $b$-ary strings representing $f_g^n(b^N)$ for an arbitrary large integer $N$. In Section \ref{S:number of digits}, we study the number of occurrences of each digit in each shortest repeating string in the $b$-ary $g$-Collatz sequence, when $g\not\equiv \modd 6 8$. Finally, in Section \ref{S: Jacobsthal}, we define two different types of generalizations of Jacobsthal numbers to express the number of each digit studied in Section \ref{S:number of digits}. \section{Notation} \label{S:notation} Every base-$b$ representation of an integer is a finite string in $\{0, 1, 2, \ldots, g\}^*$, which is the set of all finite strings consisting of digits $0, 1, 2, \ldots, g$. The set $\{0, 1, 2, \ldots, g\}^*$ also includes the \textit{empty string}, which contains no digits, denoted by $\epsilon$ \cite{Sha}. The notation for the number of digits in a string is as follows: \begin{notation} \cite{Sha} For any finite string $x$ and a digit $a$, let $|x|$ denote the number of digits in $x$, and $|x|_a$ denote the number of occurrences of digit $a$'s in $x$. \end{notation} \begin{lemma}\label{L:sharp} For any string $x$ in $\{0, 1, 2, \ldots, g\}^*$, $$ |x|=\sum_{i=0}^{g}|x|_i. $$ \end{lemma} For example, $|01011|=5$, $|01011|_0=2$, $|01011|_1=3$, and $5=2+3$. The following operation shows how to create a new string from given ones \cite{Sha}: \begin{definition} For any strings $x$ and $y$ and any positive integer $n$, the \textit{concatenation} of $x$ and $y$, denoted by $xy$, is the string obtained by joining $x$ and $y$ end-to-end, and $x^n$ denotes the concatenation of $n$ $x$'s. That is, if $x=a_1a_2\cdots a_{|x|}$ and $y=b_1b_2\cdots b_{|y|}$ for some $a_i, b_i \in \{0, 1, 2, \ldots, g\}$, $$ xy=a_1a_2\cdots a_{|x|} b_1b_2\cdots b_{|y|} \text{, and } x^n=xx\cdots x \text{ ($n$ times)}. $$ For a convention, $x^{0}$ is defined to be $\epsilon$. \end{definition} \begin{lemma} For any strings $x$ and $y$ and a nonnegative integer $n$, $|xy|=|x|+|y|$ and $|x^n|=n|x|$. \end{lemma} For example, $101\text{ }00=10100$, $(10)^{ 3} =101010$, and $1=1\text{ } (10)^{ 0}$. Then, $|101\text{ }00|=|101|+|00|=3+2=5$, $|(10)^{ 3}|=3|10|=3\cdot 2 =5$, and $|\epsilon|=|(10)^0|=0$. Since the base-$b$ representation of an integer is a string in $\{0, 1, 2, \ldots, g\}^*$, we call the base-$b$ representation of an integer as a \textit{$b$-ary string} throughout this paper. When we have to distinguish an integer and its $b$-ary string, we use the following notation. \begin{notation} For any integer $m$ with its base-$b$ representation $x$, we write $m=[x]_b$ or $(m)_b=x$. \end{notation} For example, $5=[12]_3$ and $(5)_3=12$. Then, $([x]_b)_b=x$ for any $b$-ary string $x$ and $[(m)_b]_b=m$ for any integer $m$. Throughout this paper, we use the convention that $m$ is an integer and $x$ is its $b$-ary string. When we apply the $g$-Collatz function $f_g$, we often phrase this in terms of how $f_g$ transforms $x$ to another $b$-ary string, and we do not mention $m$. \begin{notation} For a $b$-ary string $x$, we let $f_g(x)$ denote the \textit{$b$-ary representation of} $f_g([x]_b)$. That is, $f_g(x)=(f_g([x]_b))_b$. \end{notation} To apply the $g$-Collatz function on a $b$-ary string, it is important to know whether a given $b$-ary string represents a multiple of $g$ or not. For any integer $m$, we let $m \bmod g$ denote the least nonnegative residue of $m$ modulo $g$, and $s_b(m)$ denote the digit sum of the base-$b$ representation of $m$. That is, $m\bmod g$ is the remainder when $m$ is divided by $g$, and if $(m)_b=a_1a_2\cdots a_{k-1} a_k$, $$ s_b(m)=\sum_{i=1}^{k} a_i. $$ It is well-known that $s_b(m)$ is congruent to $m$ modulo $g$. Hence, \begin{equation}\label{E:rg} m\bmod g \equiv \modd{s_b(m)} g. \end{equation} For a convention, we define the notation for the sum of digits in $x$, and the remainder when $[x]_b$ is divided by $g$, for any $b$-ary string $x$. \begin{definition}\label{D:sb rb} For any $b$-ary string $x$, we let $s(x)$ and $r(x)$ denote as follows: $$ s(x)= \begin{cases} s_b([x]_b), & \mbox{if $x\neq \epsilon$;} \\ 0, & \text{if $x=\epsilon$,} \end{cases} \text{ and } r(x)= \begin{cases} [x]_b \bmod g, & \text{if $x\neq \epsilon$;}\\ 0, &\text{if $x=\epsilon$.} \end{cases} $$ \end{definition} \begin{lemma} For any $b$-ary string $x$, $r(x)\equiv \modd{s(x)} g$. \end{lemma} To simplify arguments, we sometimes use the following notation. \begin{notation} For any integers $a$ and $b$, let $a\equiv_g b$ denote $a\equiv \modd b g$. \end{notation} \section{Generalized Collatz functions}\label{S:modifed} For any nonzero digit $a\in\{0, 1, 2, \ldots, g\}$, the product $g\cdot a$ can be represented by a $b$-ary string of length $2$, whose digit sum is $g$. \begin{lemma}\label{L:multiple of g} For any $a\in\{1, 2, \ldots, g\}$, the product $g\cdot a=[a-1, b-a]_b$ and the sum $s_b(g\cdot a)=g$. \end{lemma} \begin{proof} Since $g=b-1$, $g\cdot a= (a-1)\cdot b+(b-a)$, so $s_b(g\cdot a)=a-1+b-a=g$. \end{proof} \begin{lemma}\label{L:qr} For any digits $a_1$ and $a_0$ in $\{0, 1, 2, \ldots, g\}$ with $a_1< g$, if $[a_1 a_0]_b=g\cdot q+r$ for $0\leq r< g$, $$ q=\begin{cases} a_1, & \text{if $a_1+a_01$, $$ a'_i=\begin{cases} r(a_1a_2\cdots a_{i-1}), & \text{if $a_i1$, let $r_i=r(a_1a_2\cdots a_{i-1})$. Then, $r_i$ is a digit $ r(a_1a_2\cdots a_{i-1})\geq g-a_i$. \end{proof} Table \ref{Table:division} shows how $f_g$ transforms digit $a$ to digit $a'$ satisfying $f_g(xay)=x'a'y'$ for any $b$-ary strings $x$, $x'$, $y$, and $y'$ with $|x|=|x'|$. \begin{table}[ht] \begin{center} \begin{tabular}{|r|rrrrcrrl|} \hline $a'$ &$r(x)=0$&$1$ & $2$ & $3$ &$\cdots$& $g-3$&$g-2$& $g-1$\\ \hline $a=0$ & 0&1 & 2 & 3&$\cdots$& $g-3$&$g-2$& $g-1$\\ 1&0&1&2&3&$\cdots$& $g-3$&$g-2$& $g$\\ 2&0&1&2&3&$\cdots$& $g-3$&$g-1$& $g$\\ 3&0&1&2&3&$\cdots$& $g-2$&$g-1$& $g$\\ $\vdots$&&&&&$\vdots$& && \\ $g-3$&0&1&2&4&$\cdots$& $g-2$&$g-1$& $g$\\ $g-2$&0&1&3&4&$\cdots$& $g-2$&$g-1$& $g$\\ $g-1$&0&2&3&4&$\cdots$& $g-2$&$g-1$& $g$\\ $g$&1&2&3&4&$\cdots$& $g-2$&$g-1$& $g$\\ \hline \end{tabular} \end{center} \caption{The image $a'$ of $a$ in $f_g(xay)=x'a'y'$} \label{Table:division} \end{table} Notice that each image digit $a'$ of digit $a$ depends on $r(x)$, and there are $g$ distinct images of each digit $a$. \begin{note}\label{N:image} For any $b$-ary strings $x_1$, $x_2$, $y_1$, and $y_2$ and any digit $a$, let $x'_1$, $x'_2$, $y'_1$, and $y'_2$ be $b$-ary strings and $a'_1$ and $a'_2$ be digits satisfying $f_g(x_1ay_1)=x'_1a'_1y'_1$ and $f_g(x_2ay_2)=x'_2a'_2y'_2$ with $|x_1|=|x'_1|$ and $|x_2|=|x'_2|$. Then, $a'_1=a'_2$ iff $r(x_1)=r(x_2)$. \end{note} Now consider the $g$-Collatz function $f_g$ on a concatenation of $b$-ary strings. \begin{lemma}\label{L:y z} For any $b$-ary strings $y$ and $z$ with $[y]_b\equiv \modd 0 g$, $$ f_g(yz)=f_g(y)f_g(z). $$ \end{lemma} \begin{proof} Since $s(y)\equiv_g [y]_b\equiv \modd 0 g$, the number $[yz]_b\equiv_g s(yz)=s(y)+s(z)\equiv_g s(z)\equiv \modd{[z]_b} g$. Hence, if $[z]_b\equiv \modd 0 g$, $[f_g(yz)]_b=\frac{[yz]_b}g$ and $$ [f_g(y)f_g(z)]_b=\left[\left(\frac{[y]_b}{g}\right)_b \left(\frac{[z]_b}{g}\right)_b\right]_b =\left[\left(\frac{[y]_b}{g}\right)_b 0^{|z|}\right]_b+\frac{[z]_b}{g} =\frac{[y0^{|z|}]_b+[z]_b}g =\frac{[yz]_b}g. $$ If $[z]_b\not\equiv \modd 0 g$, the string $f_g(z)=f_g(za)$, where $a=g-r(z)$ by Lemma \ref{L:gen collatz odd}. Since $[yz]_b\equiv \modd{[z]_b} g$, the remainder $r(yz)=r(z)$. Hence, $a=g-r(yz)$, so $f_g(yz)=f_g(yza)$. Since $[za]_b\equiv \modd 0 g$, the string $f_g(yz)=f_g(yza)=f_g(y)f_g(za)=f_g(y)f_g(z)$. \end{proof} \begin{theorem}\label{T:y1234} For any $b$-ary strings $y_i$'s and $z$, if $[y_i]_b \equiv \modd 0 g$ for all $i$, \begin{equation}\label{E:z} f_g(y_1y_2\cdots y_k z)=f_g(y_1)f_g(y_2)\cdots f_g(y_k)f_g(z). \end{equation} \end{theorem} \begin{proof} Since $[y_i]_b\equiv \modd 0 g$ for all $i$, by Lemma \ref{L:y z}, $f_g(y_1y_2\cdots y_kz)=f_g(y_1)f_g(y_2\cdots y_{k} z)$. Continuing this, (\ref{E:z}) is obtained. \end{proof} In order to study a lengthy $b$-ary $g$-Collatz sequence with repeating digits in the following section, we present the following corollaries and theorem. \begin{corollary}\label{C:separate power of x} For any $b$-ary string $x$ and $z$ and for any positive integer $k$, if $\gcd([x]_b, g)=d$, $$ f_g(x^kz)=\left(f_g(x^{\frac g d})\right)^{\left\lfloor\frac{dk}{g}\right\rfloor} f_g(x^{k\bmod{\frac g d}}z). $$ \end{corollary} \begin{proof} Since $k=\frac g d \left\lfloor\frac{dk}{g}\right\rfloor+k \bmod{\frac g d}$, the string $x^k=(x^{\frac g d})^{\left\lfloor\frac{dk}{g}\right\rfloor} x^{k\bmod{\frac g d}}$. Since $ [x^{\frac g d}]_b\equiv_g s(x^{\frac g d})=\frac g d \cdot s(x)\equiv_g\frac g d [x]_b\equiv_g g\cdot\frac{[x]_b}d\equiv \modd 0 g, $ we can apply Theorem \ref{T:y1234}. \end{proof} \begin{theorem}\label{T:set} For any $b$-ary string $x$ and digits $a_i$'s, if $x=a_1a_2\cdots a_{|x|}$ and $\gcd([x]_b, g)=1$, the $b$-ary string $f_g(x^g)=a'_{1}a'_{2}\cdots a'_{g|x|}$ for some digits $a'_i$'s, where $$ \{a'_{k},a'_{|x|+k},\ldots, a'_{(g-1)|x|+k}\}=\{a\in\{0, 1, 2, \ldots, g\}| a\neq g-a_k\}. $$ for any $k=1, 2, \ldots, |x|$. \end{theorem} \begin{proof} Since $[x^g]_b\equiv_g s(x^g)=g\cdot s(x)\equiv\modd 0 g$, the number $|f_g(x^g)|=|x^g|=g|x|$. Hence, $f_g(x^g)=a'_{1}a'_{2}\cdots a'_{g|x|}$ for some digits $a'_i$'s. Let $a_{i|x|+k}$ be the $(i|x|+k)$-th digit in the string $x^g$. Then, for any $i$ and $j$ with $0\leq i\neq j\leq g-1$, the digit $a_{i|x|+k}=a_{j|x|+k}$ but $r(a_1a_2\cdots a_{i|x|+k})\neq r(a_1a_2\cdots a_{j|x|+k})$. (If so, $r(x^i)=r(x^j)$. Then, $i\cdot [x]_b\equiv_g i\cdot s(x)=s(x^i)\equiv_g s(x^j)=j\cdot [x]_b\equiv \modd {j\cdot r(x)} g$, so $(i-j)\cdot[x]_b\equiv 0\text{ (mod $g$)}$, which is impossible, since $\gcd([x]_b,g)=1$ and $0\leq i\neq j\leq g-1$.) Hence, $a'_{i|x|+k}\neq a'_{j|x|+k}$ by Note \ref{N:image}, so $|\{a'_{k},a'_{|x|+k},\ldots, a'_{(g-1)|x|+k}\}|=g$. Since $a'_{i|x|+k}\neq g-a_k$ by Corollary \ref{C:image}, the set $\{a'_{k},a'_{|x|+k},\ldots, a'_{(g-1)|x|+k}\}$ collects every possible image of $a_k$ by $f_g$. That is, the set $\{a'_{k},a'_{|x|+k},\ldots, a'_{(g-1)|x|+k}\}$ contains every digit in $\{0, 1, 2, \ldots, g\}$ except $g-a_k$. \end{proof} \begin{corollary}\label{C:set1} For any $b$-ary string $x$ and digit $a\in \{0,, 1, 2, \ldots, g\}$, if $\gcd([x]_b, g)=1$, \begin{equation}\label{E:fxga} |f_g(x^g)|_a=|x|-|x|_{g-a}. \end{equation} \end{corollary} \begin{proof} Theorem \ref{T:set} shows that every digit $a'$ in the string $x$ is transformed to $g$ distinct digits in $f_g(x^g)$, and each new digit $a$ in $f_g(x^g)$ cannot be equal to $g-a'$. That is, every digit $a$ in $f_g(x^g)$ is obtained by transforming digit $a'$ in $x$, where $a'\neq g-a$, and there is no other way to obtain digit $a$ in $f_g(x^g)$. Hence, $$ |f_g(x^g)|_a=\sum_{a'\neq g-a} |x|_{a'}=\sum_{a'=0}^{g}|x|_{a'}- |x|_{g-a}=|x|-|x|_{g-a}. $$ \end{proof} \begin{corollary}\label{C:x mod f_g(x)} For any $b$-ary string $x$, if $\gcd([x]_b, g)=1$, $$ [f_g(x^g)]_b\equiv \begin{cases} \modd{[x]_b+\frac g 2} g , &\text{if $g$ is even and $|x|$ is odd;} \\ \modd{[x]_b} g , &\text{otherwise.} \end{cases} $$ \end{corollary} \begin{proof} By Corollary \ref{C:set1}, $$ \begin{aligned} \left[f_g(x^g)\right]_b\equiv_g s(f_g(x^g)) =\sum_{a=0}^{g} a|f_g(x^g)|_a &=\sum_{a=0}^{g} a(|x|- |x|_{g-a})\\ &\equiv_g |x|\sum_{a=0}^{g}a +\sum_{a=0}^{g}(g-a)|x|_{g-a}\\ &= \frac{g(g+1)}{2}|x|+ s(x)\\ &\equiv_g \frac{g(g+1)}{2}|x|+ [x]_b. \end{aligned} $$ If $g+1$ or $|x|$ is even, the number $\frac{g(g+1)}{2}|x|\equiv \modd 0 g$, so $\left[f_g(x^g)\right]_b \equiv \modd{[x]_b} g$. If $g+1$ and $|x|$ are odd, $g$ is even and $|x|=2k+1$ for some integer $k$. Hence, $$ \frac{g(g+1)}{2}|x|= \frac{g}{2}(g+1)(2k+1) \equiv_g \frac g 2 \cdot 2k+\frac g 2=gk +\frac g 2\equiv_g \frac g 2. $$ \end{proof} \section{$b$-ary $g$-Collatz sequences}\label{S:sequence} Consider a sequence of $b$-ary strings generated by the $g$-Collatz function $f_g$, starting with a $b$-ary string $1 0^N$ for any arbitrary large positive integer $N$. For example, when $g=3$, $b=4$. Then, the first few strings in the $4$-ary $3$-Collatz sequence starting with the string $1 \phantom{.} 0^{60}$ are as follows: $$ \begin{array}{rl} 1\text{ } 0^{60}&=1000000000000000000000000000000000000000000000000000000000000;\\ f_3^1(1\text{ } 0^{ 60})&=01111111111111111111111111111111111111111111111111111111111112;\\ f_3^2(1\text{ } 0^{ 60})&=001301301301301301301301301301301301301301301301301301301301303;\\ f_3^3(1\text{ } 0^{ 60})&=0002113231002113231002113231002113231002113231002113231002113233;\\ f_3^4(1\text{ } 0^{ 60})&=0000302210112013321223131033000302210112013321223131033000302211. \end{array} $$ Since digit $0$ repeats in the initial string $10^N$, there exists a substring repeats in $f_g^n(10^N)$, ignoring the head digit and a tail string. For example, when $g=3$, the substrings $013$ and $002113231$ repeat in the $4$-ary strings $f_3^2(1\text{ }0^{60})$ and $f_3^3(1\text{ }0^{60})$, respectively. \begin{definition}\label{D:repeating s} Let $N$ be an arbitrary large integer. For any positive integer $n$ and any $g$-Collatz function $f_g$, the $n$th repeating string $u_{gn}$ is defined as the shortest string in the $b$-ary string $f_g^n(10^N)$ such that $$ f_g^n(10^N)=0(u_{gn})^{\left\lfloor\frac{N}{|u_{gn}|}\right\rfloor}t $$ for some $b$-ary string $t$. \end{definition} For example, $u_{3n}$ for $n=1, 2, 3, 4$ is as follows: $$ \begin{array}{l} u_{31}=1;\\ u_{32}=013;\\ u_{33}=002113231;\\ u_{34}=000302210112013321223131033.\\ \end{array} $$ Since $r(10^N)=1$ for any $g\geq 2$, the string $f_g(10^N)=01^N2$. Hence, $u_{g1}=1$ for any $g\geq 2$. Then, by Theorem \ref{T:gen collatz}, $u_{g2}=f_g(1^g)=012\ldots (g-3)(g-2)g $. For example, $u_{g2}$ for $g=2, 3, \ldots, 9$ is as follows. $$ \begin{array}{c|cccccccc} g & 2 & 3 & 4 & 5& 6&7&8 &9 \\ \hline u_{g2} & 02 & 013 & 0124 & 01235&012346&0123457&01234568&012345679 \end{array} $$ Then, $|u_{g2}|=g$, and $[u_{g2}]_b\equiv \modd 1 g$ if $g$ is odd; $\modd {1+\frac g 2} g$ if $g$ is even, by Corollary \ref{C:x mod f_g(x)}. Hence, $\gcd([u_{g2}]_b, g)=1$ for odd $g$. For even $g$, we consider two cases: $g=4k$ or $4k+2$ for some integer $k$. If $g=4k$, the number $[u_{g2}]_b\equiv_g 1+\frac g 2 =1+2k$. Since $\gcd(1+2k, k)=1$ and $\gcd(1+2k, 4)=1$, $\gcd(1+2k, 4k)=1$. If $g=4k+2$, the number $[u_{g2}]_b\equiv_g 1+\frac g 2 =2(k+1)$. Since $\gcd(k+1, 2k+1)=1$, $\gcd(2(k+1), 2(2k+1))=2$. Hence, $$ \gcd([u_{g2}]_b, g)=\begin{cases} 1, & \text{if $g\not\equiv \modd 2 4$;} \\ 2, & \text{if $g\equiv \modd 2 4$.} \end{cases} $$ Therefore, by Corollary \ref{C:separate power of x}, the string $u_{g3}=f_g(u_{g2}^g)$ if $g\not \equiv \modd 2 4$; $(u_{g2}^{\frac g2})$ otherwise. For example, $u_{g3}$ for $g=3, 4, 5, 6$ is as follows. $$ \begin{array}{c|cccc} g & 3 & 4 & 5 &6\\ \hline u_{g3} & 002113231 & 0014340322421131 & 0014211253224043351545031&001405446153223631 \end{array} $$ \begin{observation} \label{O:repeaating string} For any integer $g\geq 2$, $$ \begin{array}{ll} u_{g1}=1; & |u_{g1}|=1;\\ u_{g2}=012\cdots (g-3)(g-2)g; & |u_{g2}|=g; \\ u_{g3}=\begin{cases} f_g(u_{g2}^g), &\text{if $g\not\equiv \modd 2 4$;} \\ f_g(u_{g2}^{\frac{g}{2}}), &\text{if $g\equiv \modd 2 4$,} \end{cases} \phantom{mm} &|u_{g3}|= \begin{cases} g|u_{g2}|=g^2, &\text{if $g\not\equiv \modd 2 4$;} \\ \frac g 2 |u_{g2}|=\frac{g^2}{2}, &\text{if $g\equiv \modd 2 4$.} \end{cases} \end{array} $$ \end{observation} To calculate the string $u_{g4}$, we need to know $\gcd([u_{g3}]_b, g)$. Since $|u_{g2}|=g$, the number $|u_{g2}|$ is even, if $g$ is even. That is, there is no such case that $g$ is even and $|u_{g2}|$ is odd. If $g\not \equiv \modd 2 4$, $\gcd([u_{g2}]_b,g) =1$. Hence, $[f_g(u_{g2}^g)]_b\equiv \modd{[u_{g2}]_b} g$ by Corollary \ref{C:x mod f_g(x)}. Therefore, \begin{equation}\label{E:gcd1} \gcd([u_{g3}]_b, g)=1\text{, if }g\not \equiv \modd 2 4\text{. } \end{equation} Consider $g\equiv \modd 2 4$. Since $u_{g3}=f_g(u_{g2}^{\frac g 2})$, let $a'_i$'s be digits satisfying $u_{g3}=a'_1a'_2\cdots a'_{\frac{g^2}{2}}$, and Theorem \ref{T:gen collatz} provides the following: For any $m=0, 1, 2, \ldots, \frac g 2-1$ and any digit $a=0, 1, 2, \ldots, g-2$, \begin{equation}\label{E:digit in ug3} \begin{array}{lll} a'_{mg+a+1}&=& \begin{cases} r(u_{g2}^m012\cdots (a-2)(a-1)), & \text{if $ag-a'$. Every odd digit $a'$ in $u_{g3}$ is obtained by transforming the digit $a$'s in $\{0, 1, 2, \ldots, g-2, g\}$, where $a=4q+2$ or $4q+3$ with $a g-a'$; $a=g$. That is, $$ \begin{array}{lllllll} \text{if $a'$ is even, } &|u_{g3}|_{a'}&=&|\{&a|&a=4q,4q+1 \text{ with } 0\leq a