cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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.

Original entry on oeis.org

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

Views

Author

Joseph L. Pe, Dec 20 2002

Keywords

Comments

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.

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