%I #8 Jun 06 2017 00:12:22
%S 0,1,1,2,2,2,1,3,1,2,2,2,2,2,2,4,2,2,2,3,3,2,2,2,2,2,1,2,2,2,1,5,2,2,
%T 2,2,2,2,1,3,1,3,2,2,2,2,1,3,2,2,2,3,3,1,1,2,2,2,2,2,2,1,1,6,2,2,2,2,
%U 2,2,1,2,1,2,2,2,2,2,2,4,2,1,1,4,4,2,2,2,2,2,1,2,2,1,1,3,1,2,2,2
%N Integer part of the ratio of even to odd terms among n, f(n), f(f(n)), ...., 1 for the Collatz function (that is, until reaching "1" for the first time), or -1 if 1 is never reached.
%C 1. The Collatz function (related to the "3x+1 problem") is defined by: f(n) = n/2 if n is even; f(n) = 3n + 1 if n is odd. A famous conjecture states that n, f(n), f(f(n)), .... eventually reaches 1. 2. It appears that a(n) > 0 for all n. The mean of {a(1), a(2), ...., a(N)} seems to be close to 3/2 for large N. That is, there are about 3 even to 2 odd terms in N, f(N), f(f(N)), ...., 1. Hence f1(n) = n/2 will be applied about three times and f2(n) = 3n+1 about two times, in N, f(N), f(f(N)), ...., 1. Heuristically, one can see why 1 must eventually be reached by N, f(N), f(f(N)), .... For example, considering a sample sequence of 3 applications of f1 and 2 applications of f2: f1(f1(f1(f2(f2(N))))) = (9/32)N + 5/16, which makes N much smaller.
%H <a href="/index/3#3x1">Index entries for sequences related to 3x+1 (or Collatz) problem</a>
%e The terms n, f(n), f(f(n)), ...., 1 for n = 12 are: 12, 6, 3, 10, 5, 16, 8, 4, 2, 1, of which 7 are even and 3 are odd. Hence a(12) = Floor(7/3) = 2.
%t f[n_] := Module[{a, i, o}, i = n; o = 1; a = {}; While[i > 1, If[Mod[i, 2] == 1, o = o + 1]; a = Append[a, i]; i = f[i]]; o]; Table[f[i], {i, 1, 100}]
%Y Cf. A078719.
%K nonn
%O 1,4
%A _Joseph L. Pe_, Dec 20 2002
%E Escape clause added to definition by _N. J. A. Sloane_, Jun 06 2017