How can I find a Hailstone number (from the Collatz sequence), such that it produces a sub-sequence containing $n$ rises and $m$ falls? The rises and falls can be in an arbitrary order. Here a rise step takes $x$ to $(3x+1)/2$, while a fall step takes $x$ to $x/2$.
2026-03-30 06:48:34.1774853314
On
Hailstone numbers producing a specific number of rises and falls
161 Views Asked by Bumbble Comm https://math.techqa.club/user/bumbble-comm/detail At
3
There are 3 best solutions below
4
On
From this I would say $$2^n(3^{-n}\mod 2^m)-1$$
EDIT:
To make a parallel with Gottfried answer (also using rational modulo), here is what we would have if we limit tfind to cases with n increases and m decreases (as the question stated), and allow to land on even numbers (not specified in the question, but mentioned by Gottfried). Since a path is cyclic in a Collatz sequence, I also included Gottfried index.
tfind($n$,$m$,$idx$) = [$2^n(3^{-n}\mod 2^m)-1+idx\cdot2^{m+n}$,$\frac{3^n(3^{-n}\mod2^m)-1}{2^m}+idx\cdot3^n$]
PARI/GP code
tf(n,m,idx)=print("[",2^n*(3^-n%2^m)-1+idx*2^(m+n),",",(3^n*(3^-n%2^m)-1)/2^m+idx*3^n,"]")
Note that the second value can be simplified to $(-2^{-m}\mod 3^n)+idx\cdot 3^n$
There is a very general solution for this problem.
I write the Collatz-orbit in terms of the powers of $2$ as $$ b = T(a, [A_1,A_2,A_3,...A_N]) $$ where the $A_k$ denote the exponents of the powers of $2$ meaning $$ b = T(a,[A]) \overset{def}{:=} b= {3 a +1 \over 2^A } $$ and $$ b = T(a,[A_1,A_2]) \overset{def}{:=} b= {{3 a +1 \over 2^{A_1} } \cdot 3+1 \over 2^{A_2} }$$ and so on.
Then the function
tfind(K)with the "key" $K=[A_1,A_2,...,A_N]$ defines the trajectory with $N$ odd steps $3x+1$ and $S=\sum_{k=1}^N A_k$ the number of even steps $x/2$ .Then if you want $m$ odd steps (increasing) and $n$ even steps with the transformation rules $(3x+1)/2$ and $x/2$ , you write
[a,b]=tfind([1,1,1...,1,1+n])with $m-1$ the numbers of $1$ and $1+n$ as obvious.The function
tfind(K)in Pari/GP goes this way:and
This gives for instance
which in the $(3x+1)/2$ and $x/2$ notation gives $2$ odd (=increasing) steps and $2-1=1$ additional decreasing ($x/2$) steps and is performed by $$b = T(a,[1,2])$$ transformation.
The optional parameter
idxallows to select further solutions $[a,b]$ :Note that all $a_k$ are in the same residue class of $2 \cdot 2^S$ where $S$ is the sum of all exponents (here $S=3$), and $b_k$ are in the same residue class of $2 \cdot 3^N$ where $N$ is the number of odd steps (here: $N=2$)
If one wants the smallest solution of $m=6$ odd steps and $n=4$ additional even steps (in terms of the $(3x+1)/2$ and $x/2$ transformation) then one calls
This is all in Pari/GP and this software allows large $N$ (in the millions) and $S$ accordingly.
A nice application is then to find a pair of $[a,b]$ which forms a "glide" (term coined by Eric Roosendaal, I think ) where the trajectory is always increasing, but very slow:
(Note that this is only a simple synthetic/schematic way. There are possibilities for other exponent-sequences which spit out smoother solutions for $[a,b]$ - meaning that the final $b$ is nearer to the initial $a$)