A078720 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.
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, 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, 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
Offset: 1
Keywords
Examples
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.
Crossrefs
Cf. A078719.
Programs
-
Mathematica
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}]
Extensions
Escape clause added to definition by N. J. A. Sloane, Jun 06 2017
Comments