On Collatz' Words, Sequences and Trees
Motivated by a recent work of Trümper we consider the general Collatz word (up-down pattern) and the sequences following this pattern. The recurrences for the first and last sequence entries are given, obtained from repeated application of the general solution of a binary linear inhomogeneous Diophantine equation. These recurrences are then solved. The Collatz tree is also discussed.
\section{Introduction}
The Collatz map $C$ for natural numbers maps an odd number $m$ to $3\,m\,+\, 1$ and an even number to \dstyle{\frac{m}{2}}.  The {\sl Collatz} conjecture  \cite{Lagarias}, \cite{WikiC}, \cite{WeissteinC} is the claim that every natural number $n$ ends up, after sufficient iterations of the map $C$, in the trivial cycle $(4,\, 2,\, 1)$. Motivated by the work of {\sl Tr\"umper} ~\cite{Truemper} we consider a general finite {\sl Collatz} word on the alphabet $\{u,\,d\}$, where $u$ (for `up') indicates application of the map $C$ on an odd number, and $d$ (for `down')  for applying the map $C$ on an even number. The task is to find all sequences which follow this word pattern (to be read from the left to the right). These sequences will be called $CS$ (for {\sl Collatz} sequence also for the plural) realizing the CW (for {\sl Collatz} word also for the plural) under consideration. This problem was solved by {\sl Tr\"umper} \cite{Truemper} under the restriction that the first and last sequence entries are odd. Here we shall not use this restriction.The solution will be given in terms of recurrence relations for the first and last entries of the $CS$ for a given $CW$. This involves a repeated application of the general solution on positive numbers of the linear inhomogeneous {\sl Diophant}ine equation $a\,x\,+\, b\,y\,=\, c$, with $a\,=\, 3^m$ and $b\,=\, 2^n$ and given integer $c$. Because $gcd(3,2)\,=\, 1$ one will always have a countable infinite number of solutions. This general solution depends on a non-negative integer parameter $k$. We believe that our solution is more straightforward than the one given in \cite{Truemper}.      
\section{Collatz words, sequences and the Collatz tree}\label{section2}
The {\sl Collatz} map $C:\ \mathbb{N} \to \mathbb{N},\ m \mapsto 3\,m\,+\, 1$ if $m$ is odd,  \dstyle{m \mapsto \frac{m}{2}} if $m$ is even, leads to an increase $u$ (for `up') or decrease $d$ (for `down'), respectively. Finite {\sl Collatz} words over the alphabet $\{u,\,d\}$ are considered with the restriction that, except for the one letter word $u$, every $u$ is followed by a $d$, because $2\,m\,+\, 1 \,\mapsto\, 2\,(3\,m+1)$. This is the reason for introducing (with \cite{Truemper}) also $s\, :=\, ud$. Thus $s$ stands for  $2\,m\,+\, 1\,\mapsto\, 3\,m\,+\, 1$. The general finite word is encoded by an $(S+1)-$tuple $\vec n_{S}\,=\, [n_0,\,n_1,\,...,\,n_S ]$ with $S\,\in\, \mathbb N$. 
\begin{eqnarray} \label{CW}
 CW(\vec n_{S+1}) &\,=\,& d^{n_0}\,s\,d^{n_1-1}\,s\, \cdots\, s\,d ^{n_S-1} \\
                              &\,=\, &   (d^{n_0}\,s)\,(d^{n_1-1}\,s)\, \cdots\, \,(d ^{n_{S-1}-1}\,s)\, d ^{n_S-1}\ , \nonumber
\end{eqnarray}
with $n_0\,\in\, {\mathbb N}_0\, :=\, {\mathbb N}\, \cup\, \{0\} $, $n_i\,\in\, \mathbb N$, for $i\,=\, 1,\,2,\,...,\, S$. The number of $u$ (that is  of $s\,=\, ud$) letters in the word $CW(\vec n_{S})$, or $CW(S)$, for short, is $S$ (which is why we have used $\vec n_S$ not $\vec n_{S+1}$ for the $S+1$ tuple), and the number of $d$ is \dstyle{D(S)\, :=\, \sum_{j=0}^{S}\,n_j }. In \cite{Truemper} $n_0\,=\, 0$ (start with an odd number), $y\,=\, S$ and $x\,=\, D(S)$.\par\smallskip\noindent
Some special words are not covered by this notation: first the one letter word $u$ with the {\sl Collatz} sequence ($CS$) of length two $CS(u;\,k)\,=\, [2\,k\,+\, 1,\, 2\,(3\,k\,+\,  2)]$, and $CW([n_0])\,=\, d^{n_0}$ with the family of  sequences $CS([n_0];k) \,=\, [2^{n_0}\,k,2^{n_0 - 1}\,k,\,...,\,1\,k] $ with  $k\,\in\, {\mathbb N}_0$. \par\smallskip\noindent
A {\sl Collatz} sequence $CS$ realizing a word $CW(\vec n_{S})$  is of length $L\,=\, D\,+\, S\,+\, 1$ and follows the word pattern from the left to the right. $CS(\vec n_{S})\,=\, [c_1,\, c_2,\,...,\,c_L]$. For example, $CW([1,2,1])\,=\, dsds$ with  $S\,=\, 2$,  $D(2)\,=\, 2$, and length $L\,=\, 7$ with $SC_0(\vec n_S) \,=\, [2, 1, 4, 2, 1, 4, 2]$ is the first of these sequences (for non-negative integers), the one with smallest start number $c_1$. In order to conform with the notation used in \cite{Truemper} we shall use for the start number $c_1\,=\, M$ and for the last number $c_L \,=\, N$. However, in \cite{Truemper} $M$ and $N$ are restricted  to be odd which will not be the case here. Later one can get the words with odd start number M by choosing $n_0\,=\, 0$. In order to have also $N$ odd one has to pick from $SC_k([0,n_1,...,n_S])$, for $k\,\in\, \mathbb N_0$ only the odd members.\par\smallskip\noindent
In \cite{Truemper} the monoid of Collatz words, with the unit element $e\,=\,$ {\it empty word} is treated. This will not be considered in this work. Also the connection to the $3\,m\,-\, 1$ problem will not be pursued here.\par\smallskip\noindent
The {\sl Collatz} tree CT is an infinite (incomplete) ternary tree, starting with the root, the number $8$ on top at level $l=0$. Three  branches, labeled $L$, $V$ and $R$ can be present:  
If a node (vertex) has label $n\,\equiv\, 4\,(mod\,6))$ the out-degree is $2$ with the a left edge (branch) labeled $L$ ending in a node with label \dstyle{\frac{n-1}{3}} and a right edge (label $R$) ending in the node labeled $2\,n$. In the other cases, $n\,\equiv\, 0,\,1,\,2,\,3,\,5,\,(mod\,6)$, with out-degree $1$, a vertical edge (label $V$) ends in the node labeled $2\,n$. The root labeled $8$ stands  for the trivial cycle $8$\, repeat$(4,\,2,\,1)$. See the {Figure 1} for $CT_7$ with only the first eight levels. It may seem that this tree is left-right  symmetric (disregarding the node labels) but this is no longer the case starting at level $l\,=\, 12$. At level $l=10$ the $mod\, 6$ structure of the left and right part of $CT$, also taking into account the node labels, is broken for the first time, but the node labels $4 (mod\, 6)$ are still symmetric. At the next level $l\,=\, 11$ the left-right symmetry concerning the labels $4 (mod\, 6)$ is also broken, leading at level $l\,=\, 12$ to a symmetry breaking in the branch structure of the left and right part of $CT$. Thus at level $l\,=\, 12$ the number of nodes becomes odd for the first time: $15$ nodes on the left side versus $14$  nodes on the right one. See rows $ l \,+\,  3$ of \seqnum{A127824} for the node labels of the first levels, and \seqnum{A005186}$(l+3)$ for the number of nodes. The number of $4\, (mod\, 6)$ nodes at level $l$ is given in \seqnum{A176866}$(l+4)$. \par\smallskip\noindent
A $CS$ is determined uniquely from its start number $M$. Therefore no number can appear twice in $CT$, except for the numbers $1,\,2,\,4$ of the (hidden) trivial cycle. The Collatz conjecture is that every natural number appears in CT at some level ($1, 2,$ and $4$ are hidden in the root $8$). A formula for $l\,=\, l(n)$ would prove the conjecture.
\par\smallskip\noindent
Reading $CT$ from bottom to top, beginning with some number $M$ at a certain level $l$, recording the edge labels up to level $l=0$, leads to a certain $L,V,R$-sequence. E.g., $M\,=\, 40$ at level $l\,=\, 5$ generates the length $5$ sequence $[V,R,V,L,V]$. This is related to the CS starting with $M\,=\, 40$, namely  $[40,20,10,5,16,8]$, one of the realizations of the CW  $d,d,d,u,d\,=\, d^3s$, with $S\,=\, 1$ and $\vec n_1\,=\, [3,1]$. (Later it will be seen that this is the realizations with the third smallest start number, the smaller once are $8$ and $24$). One has to map $V$ and $R$ to $d$ and $L$ to $u$. This shows that the map from a $L,V,R$-sequence to a CW is not one to one. The numbers $n\,\equiv\, 4\, (mod\ 6)$ except $4$ (see \seqnum{A016957}) appear exactly in two distinct CS. For example, $64 \,\equiv\, 4\,(mod\, 6)$ shows up in all $CS$ starting at any vertex which descends from the bifurcation at $64$, {\it e.g.},\, $21,\,128$; $42,\,256$; $84,\,85,\,512$; \, {\it etc.}\,  \par\bigskip\noindent

\par\smallskip\noindent
\parbox{16cm}{\begin{center}
{\includegraphics[height=10cm,width=.8\linewidth]{CollatzTree}}
\end{center}
}
\par\smallskip\noindent
\hskip 6cm {\bf  Figure: Collatz Tree $\bf CT_7$} 


\section{Solution of a certain linear inhomogeneous Diophantine equation}\label{section3}
The derivation of the recurrence relations for the start and end numbers $M$ and $N$ of {\sl Collatz} sequences ($CS$) with prescribed up-down pattern (realizing  a given  $CW$) we shall need the general solution of the following linear and inhomogeneous {\sl Diophant}ine equation.  
\begin{equation}\label{Diophant}
D(m,n;c):\hskip 2cm 3^m\,x\,-\, 2^n\,y\,=\, c(m,n),\ \ m\,\in\, \mathbb N_0, \ n\,\in\, \mathbb N_0,\ c(m,n) \,\in\, \mathbb Z\ .
\end{equation}
It is well known \cite{NZM}, pp. 212-214, how to solve the equation $a\,x\,+\, b\,y\,=\, c$
for integers $a,\, b$ (not $0$) and $c$ provided $g\,=\, gcd(a,\,b)$ divides $c$ (otherwise there is no solution) for integers $x$ and $y$. One will find a sequence of solutions parameterized by $t\,\in\, \mathbb Z$. Then one has to restrict the $t$ range to obtain all positive solutions. The procedure is to find first a special solution $(x_0,\, y_0)$ of the equation with $c\,=\, g$. Then the general solution is $(x\,=\, \frac{c}{g}\, x_0\,+\, \frac{b}{g}\, t,\, y\,=\, \frac{c}{g}\, y_0\,-\, \frac{a}{g}\, t)$ with $t\,\in\, Z$. The proof is found in \cite{NZM}. For our problem $g\,=\, gcd(3^m,\, 2^n)\,=\, 1$ for non-negative $m,\, n$ which will divide any $c(m,\, n)$. \par\bigskip\noindent
\begin{lemma}\label{SolDiophant} {\bf Solution of $\bf D(m,n;c)$}\par\smallskip\noindent    
{\bf a)} A special positive integer solution of  D(m,n;1) is\par\smallskip\noindent
\begin{eqnarray}\label{x0y0}
y_0(m,n) &\,=\,& \left(\frac{3^m\,+\, 1}{2}\right)^{n\,+\, 3^{m-1}}\, (mod\, 3^m)\ , \nonumber\\
x_0(m,n) &\,=\,& \frac{1\,+\, 2^n\,y_0(m,n)}{3^m}\ .
 \end{eqnarray}
 {\bf b)} The general solution with positive $x$ and $y$ is\par\smallskip\noindent
\begin{eqnarray}\label{Solxy}
x(m,n) &\,=\,& c(m,n)\,x_0(m,n)\,+\, 2^n\,t_{min}(m,n;sign(c)) \,+\, 2^n\,k \ ,\nonumber  \\
y_0(m,n) &\,=\,& c(m,n)\,y_0(m,n)\,+\, 3^m\,t_{min}(m,n;sign(c)) \,+\, 3^m\,k \ ,
 \end{eqnarray}
with $k\,\in\, \mathbb N_0$, and 
\begin{equation}\label{tmin}
t_{min}(m,n;sign(c))\,=\, {\Caseszwei{\ceil{\abs{c(m,n)}\,\frac{x_0(m,n)}{2^n}}}{${\rm if} \ c\,<\, 0 \ ,$} {\ceil{-c(m,n)\,\frac{y_0(m,n)}{3^m}}} {${\rm if} \ c\,\geq\,  0\ .$}}
\end{equation}
\end{lemma}
\noindent
For the proof we shall use the following {\sl Lemma}:
\begin{lemma}\label{Anm}    
$ A(n,m)\, :=\, {\binomial{n-1}{m-1}}\, \frac{gcd(m,n)}{m}$\, is a positive integer for $ m\,=\, 1,\,2\, ...\, n,\  n\,\in\, \mathbb N$\, .
\end{lemma}
\begin{proof}\par\smallskip\noindent
[due to {\sl Peter Bala}, see \seqnum{A107711}, history, Feb 28 2014]:\par\noindent 
This is the triangle \seqnum{A107711} with A(0,0) =1. 
By a rearrangement of factors one also has  \dstyle{A(n,m)\,=\, {\binomial{n}{m}}\,\frac{gcd(n,m)}{n}}. Use $gcd(n,m)\,lcm(m,n)\,=\, n\, m$ ({\it e.g.},\, \cite{FR}), theorem 2.2.2., pp. 15-16, where also the uniqueness of the $lcm$ is shown). \dstyle{A(n,m)\,=\, \frac{a(n,m)}{lcm(n,m)}} with \dstyle{a(n,m)\,=\, {\binomial{n}{m}}\,m}, a positive integer because the binomial is a combinatorial number. $m\,|\, a(n,m)$ and $n\,|\, a(n,m)$ because \dstyle{a(n,m) \,=\, n\,{\binomial{n-1}{m-1}}} by a rearrangement. Hence $a(n,m)\,=\, k_1\,m\,=\, k_2\,n$, {\it i.e.},\, $a(n,m)$ is a common multiple of $n$ and $m$ (call it $cm(n,m)$). $lcm(n,m)\,|\, a(n,m)$ because $lcn(n,m)$ is the (unique) lowest $cm(n,m)$. Therefore \dstyle{\frac{a(n,m)}{lcm(n,m)}\,\in\, \mathbb N}, since only natural numbers are in the game.   
\end{proof}\noindent
Now to the proof of  {\sl Lemma\ 1}.\par\noindent
\begin{proof} \par\smallskip\noindent
{\bf a)}  \dstyle{x_0(m,n) \,=\, \frac{1\,+\, 2^n\,y_0(m,n)}{3^m}} is a solution of $D(m,n;1)$ for any $y_0(m,n)$. The given $y_0(m,n)$ is a positive integer $\,\in\, \{1,\,2,\,...,\, 3^{m}\,-\, 1\},\  m\,\in\, \mathbb N$ and $y_0(0,n)\,=\, 1$ for $n\,\in\, \mathbb N_0$. One has to prove that $x_0(m,n)$ is a positive integer. This can be done by showing that $1\,+\, 3^n\,y_0(n,m)\,\equiv\, 0\,(mod\,3^m)$ for $m\,\in\, \mathbb N$. One first observes that \dstyle{\frac{3^m\,+\, 1}{2}\,\equiv\, \frac{1}{2}\,(mod\, 3^m)}, because obviously \dstyle{2\,\frac{3^m\,+\, 1}{2} \,\equiv\, 1\, (mod\, 3^m)} ($2$ is a unit in the ring $\mathbb Z_{3^m}$). For $m\,=\, 0$ one has $x_0(0,n) \,=\, 1\,+\, 2^n$, $n\,\in\, \mathbb N_0$, which is positive. In the following $m\,\in\, \mathbb N$.  
\begin{equation}
1\,+\, 2^n\,\left(\frac{3^m\,+\, 1}{2}\right)^{n+3^{m-1}} \,\equiv\, 1 + 2^n\, \left(\frac{1}{2}\right)^{n+3^{m-1}} \,\equiv\, 1\,+\,  \left(\frac{1}{2}\right)^{3^{m-1}}\, (mod\, 3^m)\ .
\end{equation}   
Now we show that \dstyle{L(m)\, :=\,  \left(\frac{3^m\,+\, 1}{2}\right)^{3^{m-1}}\,\equiv\, 0\, (mod\, 3^m)} by using \dstyle{\frac{3^m\,+\, 1}{2} \,=\, 3\, k(m)\,-\, 1} with  \dstyle{k(m)\, :=\, \frac{3^{m-1}\sspp1}{2}}, a positive integer. The binomial theorem leads with $ a(m)\,=\, 3^{m\,-\, 1}$ to
\begin{eqnarray}
(3\,k(m)\,-\, 1)^{a(m)} &\,=\,& \sum_{j=0}^{a(m)-1}\,{\binomial{a(m)}{j}}\, (-1)^j\, (3\,k(m))^{a(m)-j} \nonumber \\
&\,=\,& 3^m\,\Sigma_1(m) \,+\, \Sigma_2(m),  {\rm with} \\
\Sigma_1(m) &\,=\,& \sum_{j=0}^{a(m)-m}\, (-1)^j\,{\binomial{a(m)}{j}}\,k(m)^{a(m)-j}\,3^{a(m)-m-j}, \ {\rm and} \\
\Sigma_2(m) &\,=\,& \sum_{j=a(m)-m+1}^{a(m)-1}\, (-1)^j\,{\binomial{a(m)}{j}}\,(3\, k(m))^{a(m)-j}\ . 
\end{eqnarray} 
$\Sigma_1(m)$ is an integer because of $a(m)-j\,\geq\,  a(m)-m-j\,\geq\,  0$  and the integer binomial, hence $L(m)\,\equiv\, \Sigma_2 \,(mod\, 3^m)$. Rewriting $\Sigma_2$ with $j'\,=\, j-a(m)+m-1$, using also the symmetry of the binomial, one has
\begin{eqnarray} 
\Sigma_2(m)&\,=\,& \sum_{j=0}^{m-2}\,{\binomial{a(m)}{j}}\, (-1)^{j-m}\,(3\,k(m))^{m-1-j}\nonumber \\
&\,=\,& \sum_{j=1}^{m-1}\,(-1)^{j+1}\, {\binomial{a(m)}{j}}\, (3\,k(m))^j \,=\, 3^m\,\widehat\Sigma_2(m)\, \ {\rm with}\\
\widehat\Sigma_2(m)&\,=\,& \sum_{j=1}^{m-1}\,(-1)^{1+j}\,{\binomial{a(m)}{j}}\,k(m)^j\,3^{j-m}\nonumber \\
&\,=\,&  \sum_{j=1}^{m-1}\,(-1)^{1+j}\,k(m)^j\,{\binomial{a(m)-1}{j-1}}\,\frac{1}{j}\,3^{j-1}\ .
\end{eqnarray}
In the last step a rearrangement of the binomial has been applied, remembering that $a(m)\,=\, 3^{m-1}$. It remains to be shown that \dstyle{A_{m,j}\, :=\,  3^{j-1}\,{\binomial{3^{m-1}-1}{j-1}}\,\frac{1}{j}} is a(positive) integer for $j\,=\, 1,\,2,\,...\,m-1$. Here {\sl Lemma 2}  comes to help. Consider there $A(3^{m-1},j)$ for $j\,=\, 1,\,2,\,...,\,m-1$  ($m=0$ has been treated separately above), which is a positive integer. If $3\, \not|\, j$ then $3^{j-1}\,A(3^{m-1},j) \,=\, A_{m,j}$, hence a positive integer. If $j\,=\, 3^k\,J$, with $k\,\in\, \mathbb N$ the largest power of $3$ dividing $j$ then $gcd(3,J)\,=\, 1$, and  $j\,=\, 3^k\,J \sspleq m-1\,<\, 3^{m-1}$ and $gcd(3^{m-1},3^k\,J)\,=\, 3^q$ with $q\,=\, min(k,m-1)$.
\end{proof}\noindent
\begin{proof} \par\smallskip\noindent
{\bf b)} The general integer solution of ~\ref{Diophant} is then (see \cite{NZM}, pp. 212-214; note that there $b>0$, here $b<0$, and we have changed $t\mapsto -t$) 
\begin{eqnarray}
x\,=\, \hat x(m,n;t)&\,=\,& c(m,n)\,x_0(m,n)\,+\, 2^n\,t\, ,\nonumber \\
y\,=\, \hat y(m,n;t)&\,=\,& c(m,n)\,y_0(m,n)\,+\, 3^m\,t\, , \ t\,\in\, \mathbb Z\,.
\end{eqnarray}
In order to find all  positive solutions for $x$ and $y$ one has to restrict the $t$ range, depending on the sign of $c$. If $c(m,n)\,\geq\,  0$  then, because $x_0$ and $y_0$ are positive and \dstyle{\frac{x_0(m,n)}{2^n}\,=\, \frac{y_0(m,n)}{3^m}\,+\, \frac{1}{2^n\,3^m}},\  \dstyle{t\,>\, -\frac{c(m,n)\,x_0(m,n)}{2^n}} and  \dstyle{t\,>\, -\frac{c(m,n)\,y_0(m,n)}{3^m}}, {\it i.e.},\, \par\noindent
\dstyle{t\,\geq\,  \ceil{max\left( - \frac{c(m,n)\,x_0(m,n)}{2^n},\, -\frac{c(m,n)\,y_0(m,n)}{3^m}\right)}} \dstyle{\,=\,  \ceil{-c(m,n)\,min\left(\frac{x_0(m,n)}{2^n},\, \frac{y_0(m,n)}{3^m}  \right)}} \par\noindent
\dstyle{\,=\, \ceil{-c(m,n)\, \frac{y_0(m,n)}{3^m} }\,=\,  t_{min}(m,n;+)}. \par\noindent
If $c(m,n)\,<\, 0$ then  \dstyle{t\,\geq\,  \ceil{ \abs{c(m,n)}\, max\left(\frac{x_0(m,n)}{2^n},\, \frac{y_0(m,n)}{3^m}\right)}\,=\, \ceil{\abs{c(m,n)}\, \frac{x_0(m,n)}{2^n}}} $\,=\,  t_{min}(m,n;-)$. Thus with $t\,=\, t_{min}(m,n;sign(c)) \,+\, k$, with $k\,\in\, \mathbb N_0$ one has the desired result. Note that $(x_0(m,n),\, y_0(m,n))$ is the smallest positive solution of the equation  $D(m,n;1)$,  eq.~\ref{Diophant}, because, for $c(m,n)\,=\, 1$, $t_{min}(m,n;+) \,=\, \ceil{-\frac{y_0(m,n)}{3^m}}$, but with $y_0(m,n)\,\in\, \{1,\,2,\,...\,3^m-1\}$ this is $0$.
\end{proof} \noindent
A proposition on the periodicity of the solution $y_0(m,n)$ follows.\par\smallskip\noindent
\begin{proposition} \label{y0Periodicity}
{\bf Periodicity of $\bf y_0(m,n)$ in $\bf n$}\par\smallskip\noindent
{\bf a)} The sequence $y_0(m,n)$ is periodic in $n$ with primitive period length $L_0\,=\, \varphi(3^m)$, for $m\,\in\, \mathbb N_0\, $ with {\sl Euler}'s totient function $\varphi(n)\,=\,$\seqnum{A000010}$(n)$, where $\varphi(1)\, :=\, 1$. 
\par\smallskip\noindent
{\bf b)} The sequence $x_0(m,n\,+\, L_0(m))\,=\, q(m)\,x_0(m,n)\,-\, r(m)$, $m\,\in\, \mathbb N_0$,  with $q(m)\, :=\, 2^{\varphi(3^m)}$ and \dstyle{r(m) \, :=\, \frac{2^{\varphi{(3^m)}}\,-\, 1}{3^m}}. See \seqnum{A152007}.\par\smallskip\noindent
{\bf c)} The set $Y_0(m)\, :=\, \{y_0(m,n) \,|\, n\,=\, 0,\,1,\,...,\, \varphi(3^m)\,-\, 1\} $, is, for $m\,\in\, \mathbb N_0$, a representation of the set $RRS(3^m)$, the smallest positive restricted residue system  modulo $3^m$. See \cite{TApostol} for the definition. The multiplicative group modulo $3^m$,  called \dstyle{\mathbb Z_{3^m}^{\times}\,=\, (\mathbb Z/3^m\,\mathbb Z)^\times} is congruent to the cyclic group $C_{\varphi(3^m)}$. See, e.g., \cite{WikiRRS},\par\smallskip\noindent
\end{proposition}
\begin{proof}\par\smallskip\noindent
{\bf a)} By {\sl Euler}'s theorem ({\it e.g.},\, \cite{FR}, theorem 2.4.4.3 on p. 32) $a^{\varphi(n)} \,\equiv\, 1\, (mod\, n)$, provided $gcd(a,n)\,=\, 1$. Now \dstyle{gcd\left(\frac{3^m+1}{2},3^m\right) \,=\, gcd\left(\frac{3^m+1}{2},3\right)\,=\, 1} because \dstyle{\frac{3^m+1}{2} \,\equiv\, \frac{1}{2}\, (mod\, 3^m)} (see above) and hence  \dstyle{\frac{3^m+1}{2} \,\not\equiv  \, 0\, (mod\, 3^m)}. This shows that $L_0(m)$ is a period length, but we have to show that it is in fact the length of the primitive period, {\it i.e.},\, we have to prove that the order of  \dstyle{\frac{3^m+1}{2}} modulo $3^m$ is $L_0(m)$. (See {\it e.g.},\, \cite{FR}, Definition 2.4.4.1. on p.31, for the order definition.) In other words we want to show that  \dstyle{\frac{3^m+1}{2}} is a primitive root (of $1$) modulo $3^m$. Assume that $k(m)$ is this order (the existence is certain due to {\sl Euler}'s theorem), hence $(\frac{1}{2})^{k(m)} \,\equiv\, 1\, (mod\, 3^m)$ and $k(m)\,|\, L_0(m)$. It is known that the module $3^m$ possesses primitive roots, and the theorem on the primitive roots says that there are precisely $\varphi(\varphi(3^m))$ incongruent ones ({\it e.g.},\, \cite{NZM}, pp. 205, 207, or \cite{Nagell}, theorem 62, 3., p. 104 and theorem, 65, p. 107). In our case this number is  $\varphi(2\cdot 3^{m-1}) \,=\, 2\cdot 3^{m-2}$ if $m \,\geq\,  1$. The important point, proven in \cite{Nagell}, theorem 65.3 on p. 107, is that if we have a primitive root $r$ modulo an odd prime, here $3$, then, if $r^{3-1}\,-\, 1$ is not divisible by $3^2$, it follows that $r$ is in fact a primitive root for any modulus $3^q$, with $q\,\in\, \mathbb N_0 $. One of the primitive roots modulo $3$ is $2$, because $2^2\,=\, 4\,\equiv\, 1\, (mod\, 3)$ and $2^1\,\not\equiv  \, 1\, (mod\ 3)$. Also $2^{3-1}\,-\, 1 \,=\, 3$ is not divisible by $3^2$, hence $2$ is a primitive root of any modulus  $3^q$ for $q\,\in\, \mathbb N_0$. From this we proof that \dstyle{\frac{3^m+1}{2}\,\equiv\, \frac{1}{2}\,(mod\, 3^m)} is a primitive root modulo $3^m$.  Consider  \dstyle{\left(\frac{3^m+1}{2}\right)^k\,\equiv\, \frac{1}{2^k}\,(mod\, 3^m)} for $k\,=\, 1,\,2,\,...,\, \varphi(3^m)$. In order to have \dstyle{\left(\frac{1}{2}\right )^k \,\equiv\, 1\, (mod\, 3^m)} one needs $2^k\,\equiv\, 1\, (mod\, 3^m)$. But due to \cite{Nagell} theorem 65.3. p. 107, for $p\,=\, 3$, a primitive root modulo $3^m$ is $2$, and the smallest positive $k$ is therefore $\varphi(3^m)$, hence \dstyle{\frac{3^m+1}{2}} is a primitive root (of $1$) of modulus $3^m$. \par\smallskip\noindent
{\bf b)} \dstyle{x_0(m,n\,+\, \varphi(3^m))\,=\,  \frac{1\,+\, 2^n\,2^{\varphi(3^m)}\,y_0(m,n)}{3^m}} from the periodicity of $y_0$. Rewritten as \dstyle{\frac{2^{\varphi(3^m)}\,\left( ( 2^{-\varphi(3^m)} \,-\, 1) \,+\, (1\,+\, 2^n\,y_0(m,n) \right)} {3^m}\,=\,}  \dstyle{-\frac{1}{3^m}\,(2^{\varphi(3^m)}\,-\, 1) \,+\, 2^{\varphi(3^m)}\,x_0(m,n)\,=\, }  \dstyle{ q(m)\, x_0(m,n) \,-\, r(m)} with the  values given in the {\sl Proposition}.\par\smallskip\noindent
{\bf c)} This follows from the reduced residue system modulo $3^m$ for  $m\,\in\, \mathbb N_0$, \par\noindent
\dstyle{\left\{ \left(\frac{1}{2}\right)^0,\,\left(\frac{1}{2}\right)^1,\, ...,\, \left(\frac{1}{2}\right)^{\varphi(3^m)\sspm1} \right\}}, because \dstyle{\frac{1}{2}} is a primitive root modulo $3^m$ (from part {\bf b)}).  With $a(m)\, :=\, \frac{3^m\,+\, 1}{2}$  one has $1\,=\, gcd(a(m),3)\,=\, gcd(a(m),3^m)\,=\, gcd(a(m)^{b(m)},3^m)$ with $b(m)\, :=\, 3^{m\,-\, 1}$, also\par\noindent
 \dstyle{\left\{a(m)^{b(m)}\, \left(\frac{1}{2}\right)^0,\,a(m)^{b(m)}\, \left(\frac{1}{2}\right)^1,\,...,\,a(m)^{b(m)}\, \left(\frac{1}{2}\right)^{\varphi(3^m)\sspm1}\right\}} is a reduced residue system modulo $3^m$ (see \cite{TApostol}, theorem 5.16, p. 113). Thus \par\noindent
\dstyle{Y_0(m)\,\equiv\, \{a(m)^{b(m)}\,1,\, a(m)^{b(m)+1},\,...,\,  a(m)^{b(m) \,+\, \varphi(3^m)\,-\, 1}\}} is a reduced residue system modulo $3^m$. Therefore this gives a permutation of the reduced residue system modulo $3^m$ with the smallest positive integers sorted increasingly.
\end{proof}     \par\smallskip\noindent
\begin{example}  For $m\,=\, 3$, $\varphi(3^3)\,=\, 2\cdot 3^2\,=\, 18\,=\, L_0(3)$, \par\noindent
$\{y_0(3,n)\}_{n=0}^{17}\,=\, \{26,\, 13,\, 20, \,10,\, 5,\, 16,\, 8,\, 4,\, 2, \,1,\, 14,\, 7,\, 17,\, 22,\, 11,\, 19,\, 23,\, 25\}$ a permutation of the standard reduced residue system modulo $27$, obtained by resorting the found system increasingly. See \seqnum{A239125}. For $m=1,\, 2$ and $ 4$ see \seqnum{A007583},\ \seqnum{A234038} and \seqnum{A239130}  for the solutions $(x_0(m,n),\, y_0(m,n))$. 
\end{example}
\par\smallskip\noindent
\section{Recurrences and their solution}\label{section4}
After these preparations it is straightforward to derive the recurrence for the start and end numbers $M$ and $N$ for any given $CW(\vec n_S)$, for $S\,\in\, \mathbb N$. \par\smallskip\noindent
{\bf A)} We first consider the case of words with $n_S\,=\, 1$. {\it i.e.},\, $\vec n_S\,=\, [n_0,\,n_1\,,...\,n_{S-1},\,1]$. This is the word $CW(\vec n_S )\,=\, \rprod_{j=0}^{S-1}\, d^{n_j}\, s$ (with an ordered product, beginning with $j=0$ at the left-hand side). In order to simplify the notation we use $M(S)$, $N(S)$, $y_0(S)$, $x_0(S)$, and $c(S)$ for $ M(\vec n_S )$, $N(\vec n_S)$ ,  $y_0(S,n_S)$,  $x_0(S,n_S)$ and $c(S,n_S)$,  respectively. 
For $S=1$, the input for the recurrence, one has
\begin{equation}
M(1;k) \,=\, 2^{n_0}\,(2\,k+1)\  \text{and}\ N(1;k) \,=\, 3\,k\,+\, 2,\ {\text for}\ k \,\in\, \mathbb N\ ,
\end{equation} 
because there are $n_0$ factors of $2$ from $d^{n_0}$, and then an odd number $2\,k\,+\, 1$ leads after application of $s$ to $3\,k\,+\, 2$. Thus $M(1)\,=\, 2^{n_0}$ and $N(1)\,=\, 2$.\par\smallskip\noindent
\begin{proposition} {\bf Recurrences for $\bf M(S)$ and $\bf N(S)$ with $\bf n_S\,=\, 1$} \label{Rec}\par\smallskip\noindent
{\bf a)} The coupled recurrences for $M(S,t)$ and $N(S,t)$, the first and last entry of the {\sl Collatz} sequences $CS(\vec n_S;t)$ for the word $ CW(\vec n_S)$ with $\vec n_S\,=\, [n_0,\,n_1,\,...\, n_{S-1},1]$  ($n_S\,=\, 1$) are \par\smallskip\noindent
\begin{eqnarray}
M(S,t)\,=\, M(S)&\,+\,& 2^{\hat D(S)}\, t\ , \nonumber \\
N(S,t)\,=\, N(S)&\,+\,& 3^S\,t\, ,\  {\rm with}\ t\,\in\, \mathbb Z\ , 
\end{eqnarray}
 where \dstyle{\hat D(S)\, :=\, \sum_{j=0}^{S-1}\,n_j} (we prefer to use a new symbol for the $n_S\,=\, 1$ case), and the recurrences for $M(S)$ and $\widetilde N(S)\,=\, N(S)\,-\, 2$ are
 \begin{eqnarray}
M(S) \,=\, M(S-1) &\,+\,& 2^{\hat D(S-1)}\,c(S-1)\, x_0(S-1) \ , \nonumber \\
 \widetilde N(S) &\,=\,& 3\,y_0(S-1)\, c(S-1)\, 
\end{eqnarray}
with
\begin{equation}
c(S-1) \,=\, 2\,(2^{n_{S-1}-2}\,-\, 1) \,-\, \widetilde N(S-1) \,=:\, A(S-1) \,-\,  \widetilde N(S-1)\ .
\end{equation}
The recurrence for $c(S)$ is\par\smallskip\noindent
\begin{equation}
c(S) \,=\, -3\,y_0(S-1)\,c(S-1) \,+\, A(S)\  , S\,\geq\,  2, 
\end{equation}
and the input is $M(1)\,=\, 2^{n_0}$, $\widetilde N(1)\,=\, 0$ and $c(1) = A(1)$.\par\smallskip\noindent
{\bf b)} The general positive integer solution is
\begin{eqnarray}
M(S;k) &\,=\, & M(S) \,+\, 2^{\hat D(S)}\,t_{min}(S-1) \,+\, 2^{\hat D(S)}\,k\,,\nonumber \\
N(S;k) &\,=\, & 2\,+\, \widetilde N(S) \,+\, 3^S\,t_{min}(S-1) \,+\, 3^S\,k, \ k\,\in\, \mathbb N_0 \, ,
\end{eqnarray} 
 where 
\begin{equation}
t_{min}(S) \,=\, t_{min}(S, n_S,sign(c(S))) \,=\, {\Caseszwei{\ceil{\abs{c(S)}\,\frac{x_0(S)}{2^{n_S}}}}{${\rm if} \ c(S)\,<\, 0 \ ,$} {\ceil{-c(S)\,\frac{y_0(S)}{3^S}}} {${\rm if} \ c(S)\,\geq\,  0\ .$}}
\end{equation} 
\end{proposition}
\begin{corollary}
\begin{eqnarray}
M(S;k) &\,\equiv\,& M(S) \,+\, 2^{\hat D(S)}\,t_{min}(S-1)\, (mod\, 2^{\hat D(S)})\, , \nonumber \\
N(S;k) &\,\equiv\,& \widetilde N(S) \,+\,  3^S\,t_{min}(S-1)\, (mod\, 3^S)\, .
\end{eqnarray}
\end{corollary} \par\smallskip\noindent
In Terras' article \cite{Terras} the first congruence corresponds to {\sl theorem 1.2}, where the encoding vector $E_k(n)$ refers to the modified {\sl Collatz} tree using only $d$ and $s$ operations.
\begin{proof} \par\smallskip\noindent
{\bf a)} By induction over $S$. For $S\,=\, 1$  the input $M(1)\,=\, 2^{n_0}$, $N(1)\,=\, 2$ or $\widetilde N(1)\,=\, 0$ provides the start of the induction. Assume that part {\bf a)} of the proposition is true for $S$ values $1,\,2,\,...,\,S-1$. To find $M(S)$ one has to make sure that $d^{n_{S-1}}\,s$ can be applied to $N(S-1;k)$, the end number of step $S-1$ sequence $CS(\vec n_{S-1};t)$ which is $N_{int}(S-1,t)\,=\, N(S-1) +3^{S-1}\, t$, with integer $t$,  by the induction hypothesis. This number has to be of the form $2^{n_{S-1}-1}\,(2\, m\sspp1)$ (one has to have an odd number after $n_{S-1}$ $d-$steps such that $s$ can be applied). Thus \dstyle{3^{S-1}\,t \,-\, 2^{n_{S-1}}\,m \,=\, 2^{n_{S-1}-1}\,-\, N(S-1) \,=\, A(S-1)\,-\, \widetilde N(S-1)\,=:\, c(S-1)}, where $\widetilde N(S-1)\,=\, N(S-1) \,-\, 2$ and $ A(S-1)\,=\, 2\,(2^{n_{S-1}-2}\,-\, 1)$. Due to {\sl Lemma}~\ref{SolDiophant} the general solution, with $t\,\to\, x(S-1,n_{S-1};t)\, \hat =\,  x(S-1;t)$, $m\,\to\, y(S-1,n_{S-1};t)\, \hat =\,  y(S-1;t)$, to shorten the notation, is
\begin{eqnarray}
t\,\to\, x(S;t) &\,=\,& c(S-1)\,x_0(S-1) \,+\, 2^{n_{S-1}}\,t \, , \nonumber \\ 
m\,\to\,  y(S;t) &\,=\,& c(S-1)\,y_0(S-1) \,+\, 3^{S-1}\,t\, , \ t\,\in\, \mathbb Z\ . 
\end{eqnarray}   
Therefore the first entry of the sequence $CS(\vec n_S;t)$ is \dstyle{M(S;t)\,=\, M(s-1,x(S-1,t))} which is
\begin{equation}
M_{int}(S;t)\,=\, M(S-1) \,+\, 2^{\hat D(S-1)}\,c(S-1)\,x_0(S-1) \,+\, 2^{\hat D(S)}\, t\, ,
\end{equation}
hence \dstyle{M(S)\,=\, M(S-1)\,+\, 2^{\hat D(S-1)}\,c(S-1)\, x_0(S-1)}, the claimed  recurrence for $M(S)$.\par\noindent
The last member of $CS(\vec n_{S-1};t)$ is $3\,m+2$ (after applying $s$ on $2\,m\,+\, 1$ from above). Thus \dstyle{N_{int}(S;t) \,=\, 3\,y(S;t)\,+\, 2}, or \dstyle{N_{int}(S;t)\,-\, 2\,=\, 3\,c(S-1)\,y_0(S-1)\,+\, 3^S\, t}. Therefore, $\widetilde N(S) \,=\, N(S)\,-\, 2 \,=\, 3\,c(S-1)\,y_0(S-1)$  the claim for the $\widetilde N$ recurrence. Note that the remainder structure of eqs. $(20)$ and $(21)$, expressed also in the {\sl Corollary}, has also been verified by this inductive proof. The recurrence for $c(S)\,=\, A(S) \,-\, \widetilde N(S)$  follows from the one for $\widetilde N(S)$. \par\smallskip\noindent
{\bf b)} Positive integer solutions from $M_{int}(S;t)$ and $N_{int}(S;t)$ of part {\bf a)} are found from the second part of  {\sl Lemma} ~\ref{SolDiophant} applied to the equation $3^{S-1}\, x \,-\, 2^{n_{S-1}}\,y\,=\, c(S-1)$, determining $t_{min}(S-1)$ as claimed. This leads finally to the formulae for $M(S;k)$ and $N(S;k)$ with $k\,\in\, \mathbb N_0$.  
\end{proof}
\begin{example} {\bf $\bf (sd)^{S-1}\,s$ Collatz sequences}\par\smallskip\noindent
Here $n_0 \,=\, 0 \,=\,  n_S $ and $n_{j}\,=\, 2$ for $j\,=\, 1,\,2\, ...,\,S-1$.
The first entries $M(S;k)$ and the last entries $N(S;k)$ of the {\sl Collatz} sequence $CS([0,2,...,2];k)$  (with $S-1$ times a $2$), whose length is $3\,S$,  are $M(S;k)\,=\, 1\,+\, 2^{2\,S-1}\,k$ and $N(S;k)\,=\, 2 \,+\, 3^S\,k$. For $S=3$ a complete {\sl Collatz} sequence $CS([0,2,2];3)$ of length $9$ is $[97, 292, 146, 73, 220, 110, 55, 166, 83]$ which is a special realization of the word $sdsds$ with start number $M(3;3)\,=\, 97$ ending in $N(3;3)\,=\, 83$. Note that for this $u-d$ pattern the start and end numbers have remainders $ M(S;0) = M(1;0) \,=\, 1$  and $N(S;0)\,=\, N(1;0) \,=\, 2$. See the tables \seqnum{A240222} and \seqnum{A240223}.
\end{example}\par\smallskip\noindent
The recurrences for $M(S)\, \hat =\,  M(\vec n_{S-1})$,  $\tilde N(S)\, \hat =\,  \tilde N(\vec n_{S-1})$ or $N(S)\, \hat =\,  N(\vec n_{S-1})$ and $c(S)\, \hat =\,  c(\vec n_{S-1}$ are solved by iteration with the given inputs $M(1)\,=\, 2^{n_0}$, $\tilde N(1)\,=\, 0$ and $c(1)\,=\, A(1)\,=\, 2\,(2^{n_0-2}\,-\, 1)$. \par\smallskip\noindent
\begin{proposition} {\bf Solution of the recurrences for $\bf n_s\,=\, 1$} \label{SolRec}\par\smallskip\noindent
The solution of the recurrences of {\sl Proposition}~\ref{Rec} with the given inputs are, for $S\,\in\, \mathbb N$:\par\smallskip\noindent
\begin{eqnarray}
c(S)&\,=\,&  A(S) \,+\, \sum_{j=1}^{S-1} \,(-3)^j\,A(S-j)\,\prod_{l=1}^j\,y_0(S-l) \, , \nonumber \\
\tilde n(S)&\,=\,& A(S) \,-\,  c(S) \,=\, -\sum_{j=1}^{S-1}\,(-1)^j\,A(S-j)\, \prod_{l=1}^{j}\,y_0(S-l)\, , \nonumber \\
N(s)&\,=\,& \tilde N(S)\,+\, 2\, , \nonumber \\
M(S) &\,=\,& 2^{n_0}\,+\, \sum_{j=1}^{S-1}\,R(S-j)\, , 
\end{eqnarray}
with \dstyle{\hat D(S)\, :=\, 1\,+\, \sum_{j=0}^{S-1}\, n_j},\  \dstyle{A(S)\, :=\, 2\,(2^{n_S-2}\,-\, 1)},\ \dstyle{R(S)\, :=\, 2^{\hat D(S)} \,x_0(S)\,c(S)}\  and $y_0(S)\, \hat =\,  y_0(S,n_S)$, $x_0(S)\, \hat =\,  x_0(S,n_S)$, given in {\sl Lemma} ~\ref{SolDiophant}.
\end{proposition}
\begin{proof}\par\smallskip\noindent
This is obvious.
\end {proof} \par\noindent
{\bf B)} The general case $n_S \,\geq\,  1$ can now be found by appending the operation $d^{n_S-1}$ to the above result. This leads to the following {\sl theorem}.\par\smallskip\noindent
\begin{theorem} \label{GenSol} {\bf The general case $\bf {\overrightarrow n}_S$} \par\smallskip\noindent
 For the Collatz word $CW(\vec n_S)\,=\, d^{n_0}\,\rprod_{j=1}^{S}\,(s\,d^{n_j-1}) \,=\, d^{n_0}\, s\,\rprod_{j=1}^{S}\,(d^{n_j-1}\, s)\,d^{n_S-1}$ (the ordered product begins with $j=1$ on the left-hand side) with  $n_0\,\in\, \mathbb N_0$ , $n\,\in\, \mathbb N$, the first and last entries of the corresponding Collatz sequences $\{CS(\vec n_S;k)\}$, of length $L(S) \,=\, n_0 \,+\, 2\,\sum_{j=1}^S n_j$,  for $k\,\in\, \mathbb N_0$, are\par\smallskip\noindent
\begin{eqnarray}
M(\vec n_S;k) &\,=\,& M(S) \,-\, 2^{\hat D(S)}\,N(S)\,x_0(S,n_S-1)\,+\, 2^{D(S)}\,t_{min}(S,n_S-1,sign(c_{new}(S)) \nonumber\\
&&  \,+\, 2^{D(S)}\,k\, , \nonumber \\
N(\vec n_S;k) &\,=\,& c_{new}(S)\,y_0(S,n_S-1)\,+\, 3^S\, t_{min}(S,n_S-1,sign(c_{new}(S))\sspp3^S\, k\ ,
\end{eqnarray}
\end{theorem}\noindent
with $c_{new}(S)\, :=\, -N(S)$, $\hat D(S) \,=\, 1\,+\, \sum_{j=0}^{S-1}\,n_j$, $D(S)\,=\, \sum_{j=0}^S\, n_j$.
\begin {proof}\par\smallskip\noindent
In order to be able to apply to the {\sl Collatz} sequences $CS([n_0,n_1,...,n_S-1,1])$ (with the results from part A) above) the final $d^{n_S-1}$ operation one needs for the last entries  $N_{int}(S;t) \,=\, N(S) \,+\, 3^S\,t \,=\, 2^{n_S-1}\,m$ with some (even or odd) integer m. The new last entries of $CS([n_0,n_1,...,n_S];t)$ will then be $m$. The general solution of $3^S\,-\, 2^{n_S-1}\,m\,=\, -N(S)\,=:\, c_{new}(S)$ is according to {\sl Lemma}~\ref{SolDiophant} \par\smallskip\noindent
\begin{eqnarray}
t\,\to\, x(S;t)&\,=\,&  c_{new}(S)\, x_0(S,n_S-1)\,+\, 2^{n_S-1}\,t,\, \nonumber \\
m\,\to\, y(S;t)&\,=\,&  c_{new}(S)\, y_0(S,n_S-1)\,+\, 3^S\,t,\,\ t\,\in\, \mathbb Z\, . 
\end{eqnarray}
This leads to positive integer solutions after the shift $t\,\to\, t_{min}\,+\, k$,  with \par\noindent
$t_{min} \,=\, t_{min}(S,n_S-1,sign(c_{new}(S)))$ to the claimed result $N(S;k)$ for the new last number of $CS(\vec n;k)$, with $k\,\in\, \mathbb N_0$. The new start value $M(S;k)$ is obtained by replacing $t\,\to\, x(S;t)$ in the old $M_{int}(S;t)$ (with $n_S\,=\, 1$). $M(S;k)\,=\, M_{int}(S,x(S;t))$ with $t\,\to\, t_{min}\,+\, k$, also leading to the claimed formula.
\end{proof} \par\smallskip\noindent
The remainder structure modulo $2^{D(S)}$ for $M(\vec n_S,k)$ and modulo $3^S$ for $N(\vec n_S,k)$ is manifest.\par\smallskip\noindent
The explicit sum versions of the results for case $n_S\,=\, 1$, given in {\sl Proposition}~\ref {GenSol}, can be inserted here.
\begin{example} {$\bf ud^{m}\,=\, sd^{m-1}$}\par\smallskip\noindent
For $m \,=\,  1,\,2,\, 3$ and $ k\,=\, 0,\,1,\,...,\,10$ one finds for $N([0,m],k)$:\par\noindent    $[2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32]$,\  $[1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31]$,\ \par\noindent
$ [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32]$, and for $M([0,m],k)$:\par\noindent 
 $[1,3,5,7,9,11,13,15,17,19,21]$,\ $[1,5,9,13,17,21,25,29,33,37,41]$,\ \par\noindent
$[5,13,21,29,37,45,53,61,69,77,85]$. Only the odd members of $N([0,m],k)$, that is the odd indexed entries, and the corresponding $M([0,m],k)$  appear in \cite{Truemper}, example 2.1. See \seqnum{A238475} for $M([0,2\,n],k)$  and  \seqnum{A238476} for  $M([0,2\,n\,-\, 1],k)$. The odd $N([0,2\,n],k)$ values are the same for all $n$, namely $5\,+\, 6\,k$, and  $N([0,2\,n-1],k)\,=\,  1\,+\, 6\,k$ for all $n\,\in\, \mathbb N$.
\end{example}  
\begin{example} {$\bf (ud)^{n}\,=\, s^{S}, S\,\in\, \mathbb N$}\par\smallskip\noindent
$\vec n_S\,=\, [0,1,...,1]$ with $S$ times a $1$. For $S \,=\,  1,\,2,\, 3$ and $ k\,=\, 0,\,1,\,...,\,10$ one finds $N(\vec n_S,k)$\ \par\noindent
 $[5,\,8,\,11,\,14,\,17,\,20,\,23,\,26,\,29,\,32]$,\ $[17,\,26,\,35,\,44,\,53,\,62,\,71,\,80,\,89,\,98]$,\ \par\noindent
$[53,\,80,\,107,\,134,\,161,\,188,\,215,\,242,\,269,\,296]$, and for $M(\vec n_S,k)$:\par\noindent
 $[3,\, 5,\, 7, \,9,\, 11,\, 13,\, 15,\, 17,\, 19, \,21]$,\ $ [7,\, 11,\, 15,\, 19, \,23,\, 27, \,31, \,35,\, 39,\, 43]$,\ \par\noindent
$[15, \,23,\, 31, \,39, \,47, \,55, \,63, \,71, \,79, \,87]$,. For odd $N$ entries, and corresponding $M$ entries this is  \cite{Truemper}, example 2.1. See \seqnum{A239126} for these $M$ values, and \seqnum{A239127} for these $N$ values, which are here $S$ dependent.
\end{example} \par\smallskip\noindent
In conclusion the author does not think that the knowledge of all {\sl Collatz} sequences with a given up-down pattern (a given {\sl Collatz} word) will help to prove the {\sl Collatz} conjecture. Nevertheless the problem considered in this paper is a nice application of a simple {\sl Diophan}tine equation.\par\bigskip\noindent
{\bf Acknowlegement}\par\smallskip\noindent
Thanks go to {\sl Peter Bala} who answered the author's question for a proof that all triangle \seqnum{A107711} entries are non-negative integers. See the history there,  Feb 28 2014.
\par\bigskip\noindent
\par\bigskip\noindent

2014-04-11T02:05:00.000
1404
1404.2710
en
https://arxiv.org/abs/1404.2710
Motivated by a recent work of Trümper we consider the general Collatz word (up-down pattern) and the sequences following this pattern. The recurrences for the first and last sequence entries are given, obtained from repeated application of the general solution of a binary linear inhomogeneous Diophantine equation. These recurrences are then solved. The Collatz tree is also discussed.
Number Theory (math.NT)
On Collatz' Words, Sequences and Trees
Qwen/Qwen-72B
1. YES
2. YES