OFFSET
1,1
COMMENTS
Recall that f(n) = n/2 if n is even; = 3n + 1 if n is odd.
EXAMPLE
n, f(n), f(f(n)), ...., 1 for n = 105, 104, respectively, are: 105, 316, 158, 79, 238, 119, 358, 179, 538, 269, 808, 404, 202, 101, 304, 152, 76, 38, 19, 58, 29, 88, 44, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1; 104, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1, of lengths 39 = 3 x 13 and 13, respectively. Hence 105 belongs to the sequence.
MATHEMATICA
f[n_] := If[EvenQ[n], n/2, 3n+1]; h[n_] := Module[{a, i}, i=n; a=1; While[i>1, a++; i=f[i]]; a]; Select[Range[2, 47000], 3h[ #-1]==h[ # ]&]
Flatten[Position[Partition[Table[Length[NestWhileList[If[EvenQ[#], #/2, 3#+1]&, n, #>1&]], {n, 50000}], 2, 1], _?(3#[[1]]==#[[2]]&), 1, Heads-> False]]+1 (* Harvey P. Dale, Apr 07 2018 *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Joseph L. Pe, Dec 29 2002
EXTENSIONS
Extended by Robert G. Wilson v, Dec 30 2002
STATUS
approved