OFFSET
1,2
COMMENTS
The hailstone (Collatz) sequence of a number is defined by repeated operations of f(x), where f(x)=x/2 if x is even, and f(x)=3x+1 if x is odd. The odd numbers of a number's hailstone sequence are also called its odd hailstone sequence.
The odd hailstone sequence of 45 [45, 17, 13, 5, 1] contains the first five terms of this sequence.
Note that a(n+1) isn't necessarily greater than a(n).
LINKS
EXAMPLE
Consider a(8): [1713, 1285, 241, 181, 17, 13, 5, 1]; the odd hailstone sequence of 1713 is descending and has length 8. 1713 is the lowest such number.
MATHEMATICA
With[{s = Array[If[AllTrue[Differences@ #, # < 0 &], Length@ #, 0] &@ Select[NestWhileList[If[EvenQ@ #, #/2, 3 # + 1] &, #, # > 1 &], OddQ] &, 10^5]}, Array[FirstPosition[s, #][[1]] &, Max@ s]] (* Michael De Vlieger, Jan 01 2020 *)
PROG
(PARI) is(k, n) = {my(x=k, v=List([])); while(x>1, if(x%2==0, x=x/2, listput(v, x); x=3*x+1)); 1+#v==n&&v==vecsort(v, , 4); }
a(n) = {k=1; while(is(k, n)==0, k+=2); k; } \\ Jinyuan Wang, Dec 31 2019
CROSSREFS
KEYWORD
nonn
AUTHOR
Xiangyu Chen, Dec 28 2019
EXTENSIONS
a(23)-a(30) from Kevin P. Thompson, Jul 23 2022
STATUS
approved